• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

correct code to my Java console(j2sdk1.4.2_03) to establish a permanent path to bin

 
Mary Dawson
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Programmers,
I have been trying to put the right input to my newly installed java console(j2sdk1.4.2_03) so that it will give a path to the bin, so that it will stop returning 'javac is not recognized as an internal or external command, operable program or batch file.' on the next line and compile the file it is required to, instead.
It has worked alright on another computer, but my attempts to make it work on this computer have thus far failed. It is a Windows XP operating system and as writ, the console is j2sdk1.4..2_03.
The input to and the response from the console thus far reads:-

Microsoft Windows XP[version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C: \ Documents and Settings\user>c:\j2sdk1.4\bin
The system cannot find the path specified

C:\Documents and Settings\user>c:\j2sdk1.4\bin
The system cannot find the path specified

C:\Documents and Settings\user>c:j2sdk1.4.1\bin;

C:\Documents and Settings\user>set PATH = C:j2sdk1.4\bin

C:\Documents and Settings\user>My Documents\java
'My is not a recognised as an internal or external command,
operable program or batchfile.

C:\Documents and Settings\user>cd My Documents\Java

C:\Documents and Settings\user\My Documents\Java>javac My First Program.java
'javac' is not recognized as an internal or external command,
operable program or batch file.

Anyway, as you can see I seem to have exhausted quite a few possibilities, trying the various code suggested by sources, and all to no avail. The file I wanted to compile and run is in a folder called 'Java' in a folder called 'My Documents', which is in a folder called 'user' which is in a folder called 'Documents and Settings' which is on the C: drive. I don't know how to get the path to the bin so that it will (preferably permanently) understand the 'javac' command so I can compile and run. Pretty elementary stuff, but it has got me stumped. Hope someone out there can help. Thank you for your assistance, in advance,
Yours
Mary Dawson

C:\Documents and Settings\user\My Documents\Java>
 
Joe Areeda
Ranch Hand
Posts: 331
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends a lot on how you start the console.

The way that works all the time is to right click on My Computer->Properties->Advanced ->Set Environment Variable (that's close I don't have an XP system available to get it exact)

Then add the correct path to bin to the list.

You can test that you have the right path by running something like
c:\>"c:\program files\java\bin\javac -version"
It will print out something like
javac 1.7.0

If you have spaces in your path like My Documents be sure to put the whole path in quotes on the command line. You do not want quotes in the path variable.

Hope that gets you close(r).

Joe
ps. One more thing. If you do this you have to open a new cmd window to get the new path.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There should be something about setting the PATH in our FAQ.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some of the problems you see happen because you have spaces in directory names and file names.

A command like this is never going to work:

javac My First Program.java

Did you really save your source code in a file named "My First Program.java" with spaces between the words? The name of your Java source code file must be the same as the name of the public class inside the source file. Since classes cannot have names with spaces in them, it makes no sense to save your source code in a filename with spaces.

For example, if your code looks like this:

then it must be saved in a file named MyFirstProgram.java (without spaces in the name).
 
Tim Moores
Bartender
Posts: 2747
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mary Dawson wrote:my newly installed java console(j2sdk1.4.2_03)

Are you aware that Java 1.4 is horribly outdated? Even the newer Java 5 is obsolete by now. if you're just starting out, you really should use Java 6.
 
Mary Dawson
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your help, I followed your instructions, it now works alright. It turned out to be version jdk 5, I was just citing 1.4 as that was the version given in the textbook, which for the purposes of giving classpaths, has proven obselete, else I wouldn't've been asking for help.
 
Mary Dawson
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- and no program wasn't really called 'My First Program' , it was called something else.
 
Joe Areeda
Ranch Hand
Posts: 331
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mary Dawson wrote:Thank you for your help, I followed your instructions, it now works alright. It turned out to be version jdk 5, I was just citing 1.4 as that was the version given in the textbook, which for the purposes of giving classpaths, has proven obselete, else I wouldn't've been asking for help.

Mary,

My take on Java versions:

1.7.x is the latest and adds some nice features to the language.
1.6.x is pretty wide spread except for some older Macs
1.5.x is pretty much compatible with everybody that uses Java.

It really depends on your audience which one you want to use. I use 1.7 if I can control distribution and 1.6 for more widespread distributions.

Joe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic