How do I compile and run Java programs on a Mac?
To clarify my earlier post, I know that you can write java in any text editor but with the PC you compile and run everything through the MS DOS prompt, what is the Mac equivalent?
See this question :-)
http://forum.java.sun.com/thread.jsp?forum=54&thread=289574
Similar Messages
-
How to Set up the variables and others to compile and Run Java Programs
Hello,
I have just downloaded the jdk1.6.0_07 and jre1.6.0_07 and installed it in C:\Program files\Java in my Windows XP ,So please tell me how to sett up the enviroment variables etc to compile and run Java Programs from Command Prompt.
thanksTo set the PATH permanently, add the full path of the jdk1.6.0_<version>\bin directory to the PATH variable. Typically this full path looks something like C:\Program Files\Java\jdk1.6.0_<version>\bin. Set the PATH as follows on Microsoft Windows:
1. Click Start > Control Panel > System on Windows XP or Start > Settings > Control Panel > System on Windows 2000.
2. Click Advanced > Environment Variables.
3. Add the location of bin folder of JDK installation for PATH in User Variables and System Variables. A typical value for PATH is:
C:\Program Files\Java\jdk1.6.0_<version>\bin -
Compile and run java programs in different directroy
Hi,
I often encounter many problems when I run java programs in the different directories. Like
javac -d dir_name a.java
java -cp dir_name a
Something wired often happens, such as, there is not a.java file in some directory, but javac -d dir_name a.java can still work or "java -cp dir_name a" often doesn't work. Moreover, file_name.jar is also a tough problem and solving compiling problems is often time-consuming.
So I hope to read something about how to compile and run java programs in different directory properly.
Could you pleae give me a detailed description for that or recommend a book or website?
Thanks a lot.Can you post a small amount of code that does not work, including the directory structure, and the error messages? Some one here can likely explain the problem.
-
Compile and run java programs using batch file
i am using eclipse to run my java programs.How to compile and run those programs using a batch file?
a) just write a batch file, and add it to the project. When you want to run it, go to a command window and invoke it. (There is probably also a way to invoke it from Eclipse)
b) if the project is complicated, take a look at ant. Eclispe knows about ant files. -
How to compile and run java files on a mac using command line?
can someone tell me or link me to some article on how to compile and run java files from command line on a mac? I have mac OS X leopard
What do you mean by "where to put them" ? What do you want to put anywhere ?
Have you read Peter's comment in brackets ? Perhaps you have a classpath problem ?
Edited by: Michael_Knight on Aug 31, 2008 4:23 AM -
How to compile and run java program at command console
hi there
can anyone tell me how to compile and run a java program at command console? I have installed JRE 1.3.1, and also have installed JBuilder 5 if it helps.try this
System.out.println("Enter your Name : ");
BufferedReader console = new BufferedReader( new InputStreamReader( System.in ) );
String s = console.readLine();
System.out.println("Hello : "+ s+" !" ); -
Compiling and running Java programs on my laptop
I have just bought a new laptop but I can't run and compile Java programs using the javac filename.java command in the command prompt. I know I have to download something but I am not sure what link. I would be grateful if somebody could send me on a URL. My O/S is Windows XP. Can somebody advise please?
If you just want to run java applications, you just need the JRE: J2SE 5.0 JRE
If you want to compile java source code, you need the JDK: J2SE 5.0 JDK
It includes also the JRE. Recommended is also the J2SE 5.0 Documentation that contains the javadoc API that describes all the Java classes.
To start develeoping I recommend the Java Tutorial: http://java.sun.com/docs/books/tutorial/ -
How to compile and run javacard program
how to compile and run javacard program "HelloWorld"
1. Where is save Servlet program?
2. How to set classpath?
3. how compile and run?
http://www.coreservlets.com -
How to develope, compile and run soap service
we want to implement the soap sevice in our concern.So its very diffcult to develope the soap program.I dont know about the soap service.please give me a input about soap and how to develope soap programs.Pls also give some sample programs and how to compile and run those programs.In our concern we are using UNIX operating system.
Thanking you
Yours faithfully
SaranYou should start by posting questions regarding web services on the correct forum ;)
Next go to xml.apache.org and read the documentation regarding Apache Axis.
You could also take a look at the Spring Framework's support for web services.
You could even take a look at the Sun Web Service tutorials.
The above resources have plenty of examples and sample code. -
Compile and run a program with Terminal
Hello, I used TextWrangler to create a .c file on my desktop. I want to compile and run the program using Terminal. However, I am new to programming and I am not sure how to achieve this. I have Xcode with Command Line Tools downloaded. I have the file "6_19.c" on my desktop currently. Any help would be appreciated.
Your Desktop probably isn't in your execution path, so you might want to start by moving "6_19.c" from your Desktop to your Home folder. After that, in Terminal, just do
gcc -o 6_19 6_19.c
The general format is
gcc -o <name you want the compiled program to have> <name of the source>.c
Do not put any .extension on the end of the name you want the compiled program to have. Also note that after "gcc" there's a space, then a dash and the next character is a lower case letter 'o', not a numerical zero. There's a space between the name of the compiled program and the name of the source.
To run the program, at your terminal prompt type
./6_19
The general format is dot forward slash <name of the compiled program>
There's no spaces at all.
Good luck. -
Help:Compiling and running Java Midlets?
Hello,
I am a fresh learner in Java.I am finding it very difficult to compile and run Java Midlets on the Computer system.Also,i will like to tranfer the Sourcecodes to a PDA i.e install it on the PDA and have the application walking well.Please help.Thank you.You will get all the detailed steps ( have a look at the ff link) to configure the sun wireless toolkit on a PC , midlet compiling, running , uploading to the Palm PDA and testing it on the device. As for the connection, you can use the hot synch cable or a bluetooth hot synch.
http://developers.sun.com/techtopics/mobility/midp/articles/palm
Cheers!,
Birhanu -
How to compile and run package programs in Java
Hi,
I want to know how to compile and run the package programs in Java using -d. instead of creating the package folder manually.
eg:
package Test;
class test1
public void disp()
//Any code;
I want to compile this without creating the folder ' Test ' manually. that is if we use -d with javac the Test folder will be created automatically. I need the format of -d
could anyone please help me.
Thanks in Advance ,
AmbikaMy program Test.java in F:\Tomcat5\webapps\Ambika\WEB-INF\Classes. I compiled in the format below. I got like this. What should I do for this? But yesterday I compiled like this only, It compiled and the folder com\cert\Test.class is created. Today again I compiled the pgm after deleting the already created folder 'com\cert', I got the error like this.
I've given my pgm and the thing I've got when I compiled it.
Test.java
package com.cert;
public class Test
public void display()
System.out.println("Hai");
F:\Tomcat5\webapps\Ambika\WEB-INF\Classes>javac -d F:\Tomcat5\webapps\Ambika\WEB-INF\Classes\Test.java
javac: no source files
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are u
sed
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
F:\Tomcat5\webapps\Ambika\WEB-INF\Classes>
Plz help me.
thanks in advance
Ambika -
How can I compile and run other java classes from within an application?
Hello there everyone! I really hope that someone can help me. I am writing a program that must be able to compile and run other java classes that are in different files, much like development environments like Kawa or Forte allow you to do.
There has to be a way of doing this ( I hope!! ), but i can't seem to find it!!
I have tried using this command to compile:
Runtime.getRuntime().exec ("c:\\programs\\javac className.java");
...and this one to run:
Runtime.getRuntime().exec ("c:\\programs\\java className");
...but neither works!!! I can compile and run classes that are in the same file as my application, but I can't get it to work at all for files in different directories or files.
PLEASE, PLEASE, PLEASE help me - i've run out of ideas, and i need this to be working in 3 days!!!
Thank you very much for any help anyone can give me, I really appreciate it!! Thanks again!!
Adrian ( ...in distress!! )public class JavaCompiler{
public static void main(String[] args)throws Exception{ //sorry bout the laziness
if(args == null || args.length != 1){
System.out.println("Usage: java JavaCompiler MyClass.java");
System.exit(0);
String className = args[0];
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("javac " + className); //consider setting cpath for this
p.waitFor();
//now try to run after it is done.
p = rt.exec("java " + className.substring(0, (className.length() - ".java".length()));
p.waitFor();
//do some other stuff
}This should get you going. You may consider looking into the System.getProperty() method in order to determine the type of OS it is running on in order to findo out what command to run. I know that the sun tool listed above is nice, but by my understanding the sun tools provided are not guaranteed to stay the same. I'm no expert on this matter, but that is one of the reasons there is no API documentation for those tools. Also, I don't believe those tools come packaged with the JRE. (Of course if you are making an IDE it will be expected that the user has an sdk installed. Good luck with figuring this thing out. -
How to compile and Run servlet Program
Hi,
pls help me the following doubt
i am using Tomacat 4.1 server.
1. Where is save Servlet program?
2. How to set classpath?
3. how compile and run?
bye
Mathi1. Where is save Servlet program?
2. How to set classpath?
3. how compile and run?
http://www.coreservlets.com -
How should I compile and run my jdbc application ?
I need help about how is the correct way for compile and run my application conecta.java using a driver postgresql-8.3-603.jdbc3.jar for connect to my database under Postgresql 8.1.4, . I have compiled as follow :
javac -cp postgresql-8.3-603.jdbc3.jar conecta.java
and I have compiled with sucessful obtaining conecta.class
but when I try using :
java conecta
a message display an error :
java.lang.ClassNotFoundException: org.postgresql.Driver
I didn find the cause , I try modifing the classpath onto .bash_profile :
# User specific environment and startup programs
JDK_HOME=/usr/local/jdk1.5.0_01
JAVA_HOME=/usr/local/jdk1.5.0_01
PATH=$JAVA_HOME/bin:/usr/lib/pgsql/bin:$HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/postgresql-8.3-603.jdbc.jar:$CLASSPATH.
export PATH CLASSPATH JAVA_HOME JDK_HOME
unset USERNAME
but the message is the same . I have downloaded the driver into the same directory where is sited concecta.class and conecta.java . I don't understand why netbeans works fine runnning my application. I will be glad if anybody help to me.
ThanksMiguel231152 wrote:
I need help about how is the correct way for compile and run my application conecta.java using a driver postgresql-8.3-603.jdbc3.jar for connect to my database under Postgresql 8.1.4, . I have compiled as follow :
javac -cp postgresql-8.3-603.jdbc3.jar conecta.javaActually, you probably don't need the JAR in the CLASSPATH to compile. You shouldn't refer to PostgreSQL classes in your code, just java.sql interfaces.
and I have compiled with sucessful obtaining conecta.class
but when I try using :
java conectaGotta have the JAR in the CLASSPATH at runtime. That's why you get that exception, and that's always what it means.
a message display an error :
java.lang.ClassNotFoundException: org.postgresql.Driver
I didn find the cause , I try modifing the classpath onto .bash_profile :
# User specific environment and startup programs
JDK_HOME=/usr/local/jdk1.5.0_01
JAVA_HOME=/usr/local/jdk1.5.0_01
PATH=$JAVA_HOME/bin:/usr/lib/pgsql/bin:$HOME/bin:$PATH:.
CLASSPATH=$JAVA_HOME/lib/postgresql-8.3-603.jdbc.jar:$CLASSPATH.Useless. Java ignores CLASSPATH environment variable.
export PATH CLASSPATH JAVA_HOME JDK_HOME
unset USERNAME
but the message is the same . I have downloaded the driver into the same directory where is sited concecta.class and conecta.java . I don't understand why netbeans works fine runnning my application. I will be glad if anybody help to me.
ThanksUse the -classpath option at runtime. That'll fix it.
%
Maybe you are looking for
-
I cannot login with my Microsoft Acount
I just installed Skype 6.14.1.104 on my desktop. And I created a new MicroSoft account: degen_iddink [at] hotmail.com When I login using Login with Microsof account I get the message my login is not recognized. Can you help me to fix this issue s
-
Is there any way to force Sun C++ Preprocessor preserve whitespace?
Hello! I'm preprocessing simple source file: void test() int i; }with command: CC -E test.cpp and CC preprocessor eats all whitespace at the beginning of each line, like this: void test() int i; }Is there any way to force CC preprocessor preserve
-
Printer wont connect when wep password enabled
Hi. I've had a HP Deskjet 5850 for many years. It worked perfectly with my D-Link wifi router, it connected wirelessly with no issues. I recently bought an airport extreme, I've reset everything on the printer and it works via ethernet, but it only w
-
What printer should I get?
Hi all, I've been doing some research into why my Epson DX4400 all-in-one won't work with my new TC, having found the problem is unlikely to be fixed by Apple or Epson any time soon, I've decided just to buy a simple ink jet to attach to the TC. I do
-
Apex4 bug: 'URL Target' textarea of button definition
Hi, at Page Definition page when listing button definitions using prev/next buttons and sticking with 'Condition' section view only, 'URL Target' textarea ( 'Action When Button Clicked' section ) doesn't preserve its size. Thanks