my dog learned polymorphism*
The moose likes Beginning Java and the fly likes correct code to my Java console(j2sdk1.4.2_03) to establish a permanent path to bin Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "correct code to my Java console(j2sdk1.4.2_03) to establish a permanent path to bin" Watch "correct code to my Java console(j2sdk1.4.2_03) to establish a permanent path to bin" New topic
Author

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

Mary Dawson
Ranch Hand

Joined: Feb 08, 2009
Posts: 36
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>


A man of words and not of deeds is like a garden full of weeds, and when the weeds begin to grow, its like a garden full of snow, and when the snow begins to fall- its like a bird upon the wall and when the bird begins to fly, its like an eagle in the sky
Joe Areeda
Ranch Hand

Joined: Apr 15, 2011
Posts: 316
    
    2

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.


It's not what your program can do, it's what your users do with the program.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38490
    
  23
There should be something about setting the PATH in our FAQ.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14116
    
  16

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).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
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

Joined: Feb 08, 2009
Posts: 36
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

Joined: Feb 08, 2009
Posts: 36
- and no program wasn't really called 'My First Program' , it was called something else.
Joe Areeda
Ranch Hand

Joined: Apr 15, 2011
Posts: 316
    
    2

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: correct code to my Java console(j2sdk1.4.2_03) to establish a permanent path to bin