This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

can't compile .java file

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm just learning Java. I've used NetBeans with java version 1.5 to compile and run a few simple apps.

Thinking i may run into probs with sdk 1.5, i uninstalled it and installed 1.4.2_09

this is what i get when i type "java -version" and "javac -version" and javac -J-version" in a command prompt window.

C:\Documents and Settings\Robert Townsend>java -version
java version "1.4.2_09"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05)
Java HotSpot(TM) Client VM (build 1.4.2_09-b05, mixed mode)

C:\Documents and Settings\Robert Townsend>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

C:\Documents and Settings\Robert Townsend>javac -J-version
'javac' is not recognized as an internal or external command,
operable program or batch file.


I don't know if i am setting my classpath correctly. I've tried a few different things, but here is what i have as the CLASSPATH for the "User Variables" and "System Variables"

"C:\j2sdk1.4.2_08\bin;C:\j2sdk1.4.2_09\myclasses"

i tried just typing "C:\j2sdk1.4.2_09\myclasses", but i still received the error: "'javac' is not recognized as an internal or external command,
operable program or batch file."

I did notice that the RunTime Environment is Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05) <-- notice the b05. I thought i read somewhere that it stood for beta and shouldn't be used, although i haven't been able to confirm that since.

Any help would be appreciated.

Regards,

Marc
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Leger:
Thinking i may run into probs with sdk 1.5, i uninstalled it and installed 1.4.2_09

C:\Documents and Settings\Robert Townsend>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

I don't know if i am setting my classpath correctly. I've tried a few different things, but here is what i have as the CLASSPATH for the "User Variables" and "System Variables"

"C:\j2sdk1.4.2_08\bin;C:\j2sdk1.4.2_09\myclasses"

I did notice that the RunTime Environment is Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05) <-- notice the b05. I thought i read somewhere that it stood for beta and shouldn't be used, although i haven't been able to confirm that since.


I'm not quite sure what sort of "problems" you were anticipating with sdk 1.5, but at this point, that seems irrelevant.

"... is not recognized as an internal or external command,
operable program or batch file." indicates that your PATH is not set correctly (not related to CLASSPATH). You should put the ""C:\j2sdk1.4.2_08\bin;" in your PATH and "C:\j2sdk1.4.2_09\myclasses" in your CLASSPATH.

I believe the 'b' stands for "build" and is not directly related to "beta". I'm using build 1.4.2_09-b05 at work with no problems.
[ October 29, 2005: Message edited by: Marilyn de Queiroz ]
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marilyn,

Thanks for replying.

I am trying to follow the instructions at http://faq.javaranch.com/view?HowToSetTheClasspath

What exactly has to be be added to the User and System Variables to get this to work? Please remember that i don't have any files yet. If you need me to create a folder to put my .java files and my .class files, let me know and i will create such a folder.

Thanks in advance,

Marc

PS

Right now, i have the following settings in the Environment variables:

User Variables: ClASSPATH
C:\j2sdk1.4.2_09\myclasses

System Variables ath
C:\j2sdk1.4.2_09\bin;C:\oracle\product\10.2.0\db_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\

I put the C:\j2sdk1.4.2_09\bin at the beginning like you suggested to someone else.
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
don't know why a smily appeared, but it should of read...

System Variables: Path
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Leger:
What exactly has to be be added to the User and System Variables to get this to work? Please remember that i don't have any files yet. If you need me to create a folder to put my .java files and my .class files, let me know and i will create such a folder.

PS

Right now, i have the following settings in the Environment variables:

User Variables: ClASSPATH
C:\j2sdk1.4.2_09\myclasses

System Variables: path



I put my .java files in C:\java (Similar to these instructions). and my CLASSPATH
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Leger:
What exactly has to be be added to the User and System Variables to get this to work? Please remember that i don't have any files yet. If you need me to create a folder to put my .java files and my .class files, let me know and i will create such a folder.

PS

Right now, i have the following settings in the Environment variables:

User Variables: ClASSPATH
C:\j2sdk1.4.2_09\myclasses

System Variables: path C:\j2sdk1.4.2_09\bin;C:\oracle\product\10.2.0\db_1\bin;...



I put my .java files in C:\java (Similar to these instructions), and my CLASSPATH is set to .;C:\java because when I compile, the .class file also appears in the C:\java directory. (Notice the '.' at the front of the CLASSPATH)

I only use System variables unless I do not have administrative rights on the computer I'm using; then I use User Variables.

Your CLASSPATH should be set to the directory that contains the .class files after you've compiled. I would keep it completely separate from the C:\j2sdk1.4.2_09 directory and its subdirectories because I like to reserve that for Sun's code.

(edit)The smiley appeared because you left out the space between the ':' and the 'P'. Just like : ) is a smiley if I leave out the space.
[ October 29, 2005: Message edited by: Marilyn de Queiroz ]
 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Marc Leger:
[QB]
Right now, i have the following settings in the Environment variables:

User Variables: ClASSPATH
C:\j2sdk1.4.2_09\myclasses

QB]



Marc, would ClASSPATH be the same as CLASSPATH? Why the lowercase L?
Classpath gives me nightmares.
The concept is very clear, but utilising it always gives me fits.
Good luck.
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I deleted any reference to Path or Classpath in the User Variables.

In my System Variables, i added a CLASSPATH(since there wasn't one before)

and it reads: .;c:\JAVA (that didn't work)

(i don't understand why there is a semi-colon in front of the variable since it is the first and only variable. So i tried the following as well:
.c:\JAVA
c:\JAVA)

Nothing worked so far. I still get the same error message:

C:\Documents and Settings\Robert Townsend>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.

Still willing to try anything,

Marc
 
Ranch Hand
Posts: 538
Hibernate Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marc !

C:\Documents and Settings\Robert Townsend>javac -version
'javac' is not recognized as an internal or external command,
operable program or batch file.


You must have normally as "System" (I mean not "User") environment variables :
_ JAVA_HOME : complete path to you Java installation directory
_ CLASSPATH : .;JAVA_HOME\lib\tools.jar
_ PATH : ...PATH...;JAVA_HOME\bin

Comments :
_ JAVA_HOME is often used by many programs fully Java written (such as Ant & Tomcat) so as to get a useable local Java instance.
_ CLASSPATH means "path to directories or files you must use for your Java program". "." is current directory where you usually go to launch your Java programs, and "tools.jar" is the Java lib which contains all needed things to run any Java program.
_ You must add "JAVA_HOME\bin" path to the already existing paths for executable programs for Java executables are there.
_ ";" is a Windows system separator to isolate items inside an environment variable, while in Unix/Linux it is ":" which is used instead.

Best regards.
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You must have normally as "System" (I mean not "User") environment variables :
_ JAVA_HOME : complete path to you Java installation directory
_ CLASSPATH : .;JAVA_HOME\lib\tools.jar
_ PATH : ...PATH...;JAVA_HOME\bin

Comments :
_ JAVA_HOME is often used by many programs fully Java written (such as Ant & Tomcat) so as to get a useable local Java instance.
_ CLASSPATH means "path to directories or files you must use for your Java program". "." is current directory where you usually go to launch your Java programs, and "tools.jar" is the Java lib which contains all needed things to run any Java program.
_ You must add "JAVA_HOME\bin" path to the already existing paths for executable programs for Java executables are there.
_ ";" is a Windows system separator to isolate items inside an environment variable, while in Unix/Linux it is ":" which is used instead.



Hi Eric,

I added a variable called JAVA_HOME c:\j2sdk1.4.2_09 is the value. (This is the folder that the .exe file created. **not sure if this is the correct path)

I created the variable called CLASSPATH .;JAVA_HOME\lib\tools.jar is the value. ( I also tried replacing the JAVA_HOME with j2sdk1.4.2_09, but it didn't work)

To the Path variable that was already there, i added ;JAVA_HOME\bin

It didn't work.

Anything else i could try?

Merci/Thanks

Marc
 
Carol Murphy
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay Marc, I went into my system files to see what I had. This is what I have in my autoexec.bat:

set ANT_HOME=c:\ant
set JAVA_HOME=c:\j2sdk1.4.2_09
set PATH_%PATH%;%ANT_HOME%\bin

REM [Header]
@ECHO OFF

REM [CD-ROM Drive]

REM [Miscellaneous]

REM [Display]

PATH=C:\j2Sdk1.4.2_09\bin;C:\J2SDK1.4.2_09\JRE\BIN;C:\java\bin;C:\ant\bin
@SET CLASSPATH=C:\PROGRA~1\PHOTOD~1.1\ADOBEC~1;.;C:\j2sdk1.4.2_09\lib;C:\java;C:\java\jr.jar;C:\j2sdkee1.3.1\lib\j2ee.jar;C:\mysql-connector-java-3.0.11-stable\mysql-connector-java-3.0.11-stable-bin.jar;C:\XT\xt.jar;C:\XML\SAX;C:\XML\xp\xp.jar;

In CLASSPATH you'll find after the first directory listed:
.;C:\j2sdk1.4.2_09\lib;C:\java;C:\java\jr.jar (then alot of j2sdkee stuff as well as mysql and XT).
Now, I may have a lot of superfluous garbage in my classpath, but being superstitious, what I've got is working, so I'm reluctant to change it.
What's in your autoexec.bat?
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Carol,

I've spent the last 90 minutes looking for the autoexec.bat file on my system. I even used to search...specifying to look in hidden folders and everything.

Can you give me a hint as to what folder to look in?

Thank you much. :-)

Marc
 
Marilyn de Queiroz
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Carol is using Win98. If you are using Win2k or WinXP, you can safely ignore the autoexec.bat file. I think the idea Carol was trying to express is what her environment variables look like.

You need the semicolon between the dot and the rest of the classpath because the dot stands for the current directory and each directory needs to be separated from the other directories by a semicolon.

However, forget you ever heard about CLASSPATH for now. The error you are getting is because your PATH is set incorrectly.

Find PATH (not CLASSPATH) in your environment variables and add C:\j2sdk1.4.2_09\bin (or the equivalent %JAVA_HOME%\bin) to the beginning of it, separating it from the following entries by a semicolon.

So if you are using Win2k or WinXP you should have something like:

%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;

After you can type javac without the error
'javac' is not recognized as an internal or external command, operable program or batch file.", then we'll worry about CLASSPATH.
[ October 31, 2005: Message edited by: Marilyn de Queiroz ]
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Here is the Path as it looks on my machine..

%j2sdk1.4.2_09%\bin;%j2sdk1.4.2_09%\jre\bin;C:\oracle\product\10.2.0\db_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\

i also tried :

%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;C:\oracle\product\10.2.0\db_1\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\

but it didn't work either.

:-)

Marc
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marc,

Let's go through Marilyn's steps from her latest post.

1. Add the following variables to the Environment Variables (I added the variables in "User Variables for Adminstrator"):


2. Reboot the system.

3. Open a command prompt and check if the PATH has been updated correctly.


You should see something like:


4. Try the java command again:



If you install the JDK 5.0 version, make sure the previous version, JDK 1.4, is completely uninstalled. Search for JDK 1.4 and JRE 1.4 in the list of Add/Remove Programs.

Joyce
[ October 30, 2005: Message edited by: Joyce Lee ]
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeeehaaaaaa!!!

That did it.

Thanks to all who help. I hope i can return the favor someday.

Best Wishes,

Marc
 
Marc Leger
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just thought i would recap what finally worked for me in case it can help someone else..

i am running windows XP

START--CONTROL PANEL--System--ADVANCED TAB--ENVIRONMENT BUTTON

User Variables: i had to add the following 2 variables:

1/"JAVA_HOME" with a value of: "c:\j2sdk1.4.2_09" --- which is where Java is installed

2/"Path" with a value of: "%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem"


To the System variable, i added the following bit of code at the BEGINNING of the Path variable that was already there.

1/ "%j2sdk1.4.2_09%\bin;%j2sdk1.4.2_09%\jre\bin;" again, you can replace "j2sdk1.4.2_09" with YOUR folder

Oh, and one last thing. I don't know if this was causing my problems, but i wasn't rebooting(restarting) my computer after every change. I only restarted it on the last change i made and it worked after that. Don't know if this was a factor or not, but it would be best to restart your computer after making changes to the User or System varibles, just in case.

Hope this helps someone,

Marc
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic