• Post Reply Bookmark Topic Watch Topic
  • New Topic

IDE vs Traditional method !!  RSS feed

 
vamsi acharya
Ranch Hand
Posts: 55
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys , I've downloaded jdk1.6 with NetBeans and installed them , When using IDE i can compile the code fine , when i want to check the code by the traditional method using the console it says 'javac' is unrecognized command , i don't understand and also in windows 'Environment variables' you can see both 'PATH' and 'CLASSPATH' , what is the difference between them ?? And can we set multiple paths ?? If so where does the compiler look for classes ? Please help me out guys , Thank you !!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
google not working?
 
vamsi acharya
Ranch Hand
Posts: 55
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael Dunn wrote:google not working?
I tried , but i couldn't understand how i get to run my code both by using IDE and the console !!
 
Matthew Brown
Bartender
Posts: 4568
9
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PATH defines where the operating system looks for executables. If you want to be able to call javac blah blah, then javac.exe needs to be in one of the folders defined by the PATH variable. It sounds like this is what you're missing.

(It should also work if you execute the command from the folder containing javac.exe, or you use the fully-qualified location C:\whatever\javac instead, but having the location in the path will make life easier for you in the long run).

CLASSPATH defines where the compiler looks for class files. Though personally I never bother trying to set that environment variable - you can set it on a per-command basis using the -cp switch. For example, if executing from the root of your source folders, you can use javac -cp . PackageName.ClassName (where the "." means "this folder"). If you want to search multiple folders, use semi-colons to separate them.

Next time you compile something with your IDE, in the output it will probably display the command it's using to do the compilation. Have a look at that, and you'll probably see the -cp (or -classpath) switch used.
 
vamsi acharya
Ranch Hand
Posts: 55
Android Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks mate , i was using fully qualified location to compile my file , now i change my path to /bin directory and it works !!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!