• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How To Compile Using Command Line

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 348
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
javac myProg.java
 
Ranch Hand
Posts: 867
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And run the executable file
java myProg
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all your help,
Daniel
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic