File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How To Compile Using Command Line Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How To Compile Using Command Line" Watch "How To Compile Using Command Line" New topic
Author

How To Compile Using Command Line

Daniel Smith
Greenhorn

Joined: Mar 19, 2004
Posts: 6
Hello,
I just installed the Java SDK and I was wondering, how do I compile my *.java file using command line?
Thanks for your help,
Daniel
chi Lin
Ranch Hand

Joined: Aug 24, 2001
Posts: 348
javac myProg.java
Francis Siu
Ranch Hand

Joined: Jan 04, 2003
Posts: 867
And run the executable file
java myProg


Francis Siu
SCJP, MCDBA
Gjorgi Var
Ranch Hand

Joined: Feb 24, 2004
Posts: 85
First month into studying Java, and I am already answering questions of other newbies... lol...
In order to compile from the command line, you have to access the folder where your .java file is. Let's say it is in "MyJavaCourse" folder on drive c, you would have to move to that folder with a DOS command "cd" and get to this:
c:\MyJavaCourse
after which you use the compile command:
c:\MyJavaCourse javac firstjavaprogram.java
and then you would get one of the following two things:
a)a newly created .class file (firstjavaprogram.class), meaning succesfull compiling, or;
b)some typical "self-explanatory" Microsoft- style error message about someone not being able to compile because of bla... in which case you should visit a dark corner on your Windows machine in the Control Panel cave (look for enviromental variable in the "System" black hole)and set the CLASSPATH variable... keep coming back at the ranch for more answers, this is a great forum...
Daniel Smith
Greenhorn

Joined: Mar 19, 2004
Posts: 6
Thanks for all your help,
Daniel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How To Compile Using Command Line