• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Basic help

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to run the basic "Hello, world!" java file but keep getting errors. My first question is, does it matter if I have both J2SE Development Kit 5.0 and Java 1.6.0.70 since I'll be specifying the file path in the command prompt?
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Please give more details of the errors; does the compiler run, does the code compile, and if so, does it run?

I think you are making life unnecessarily difficult for yourself setting the PATH from the command line; set the path permanently (there are links from the common problems page) and you won't need to do it until you upgrade your Java installation.
You ought not to have any difficulty having two versions installed; you are simply using whichever appears first in your PATH and ignoring the other.
 
Julie Nelson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I have the file saved on my desktop as Hello.java and when I type "javac Hello.java" I get an error saying, "Javac is not recognized as an internal or external command..." To my understanding that error message is saying it's not recognizing the path where the file is saved, correct? If so I don't get it since I'm clearly stating the path in the command prompt. And does it matter if when I click on the properties of my saved file the type of file says, "jGRASP Java file"?


C:\Documents and Settings\Juliet>cd desktop

C:\Documents and Settings\Juliet\Desktop>javac Hello.java
'javac' is not recognized as an internal or external command,
operable program or batch file.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

To my understanding that error message is saying it's not recognizing the path where the file is saved, correct? If so I don't get it since I'm clearly stating the path in the command prompt.



No. It's not complaining about the java file. It's windows complaining that "javac" (the java compiler) is not found in the path specified.

Henry
 
Julie Nelson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So if the javac is in a different path how do I get it to work with a file that's in another path? Do I type both paths, combined in one line, for it to register?
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Julie Nelson:
So if the javac is in a different path how do I get it to work with a file that's in another path? Do I type both paths, combined in one line, for it to register?




Well, that's one way to do it. Another way is to add it to Window's PATH -- just like with all the other programs you installed on Windows.

Henry
 
Julie Nelson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's say I have my javac in drive C:\Program Files\Java\jdk1.5.0\bin (and javac is in the bin file) but I have my Hello.java saved under C:\Documents and Settings\Juliet\Desktop...if my current path says, "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\" then I just add the C:\Program Files\Java\jdk1.5.0\bin to it? Or do I delete the part of the path that says, "\QuickTime\QTSystem\ and replace that with "\Java\jdk1.5.0\bin ?
 
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just add a ";" at the end of your path and then tell the computer where you have the bin directory installed on your machine. Do NOT delete the rest of your path variable or other things may stop working.
 
Julie Nelson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So my beginning path was this:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\


Then all I do is add what's below:
;C:\Program Files\Java\jdk1.5.0\bin


So the end result will look like the following?

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.5.0\bin
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's exactly right. After setting this, you will need to open a new Command Prompt window for this to take effect.

If you would rather use the Java 1.6 version, then specify that location instead of the Java 1.5 path. (The PATH is checked from left to right, and your system will use the first one that works.)
 
Julie Nelson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So now that I have the path updated I am to open the command prompt. Currently my command prompt is directed to C:\Documents and Settings\Juliet.

Am I supposed to change that so it points to the direction of the Hello.java file, which would be C:\Documents and Settings\Juliet\Desktop (since I saved the file to my desktop) and once that's set will I type in the "javac.Hello.java"?
 
Julie Nelson
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nevermind that last question. It worked! Thank you all for your help, I really appreciate it!!!
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done sorting it out. Suggest you create a "java" folder somewhere convenient; you will end up with hundreds of .java files all over your desktop otherwise.
 
I just had the craziest dream. This tiny ad was in it.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic