File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Path and Classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Path and Classpath" Watch "Path and Classpath" New topic
Author

Path and Classpath

martin barfield
Greenhorn

Joined: Feb 13, 2006
Posts: 9
I have been trying all day to set my path and classpath so I can run javac and java from the Windows XP command line. I am taking an online class and can't get past this first step that is required. I feel like I have a decent grasp of the java language but this problem is holding everything up. I have tried using multiple resources to figure out how to get it done with zero luck. I even bought a PC because all of the instruction was PC based, I already have a Mac. I am ready to throw the PC out the window just about now. Can anyone help or point me in the right direction?

Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
I would leave the CLASSPATH blank for now.

To set the PATH, if you go to Control Panel, System, Advanced, Environment Variables, you can set the PATH there.

Just make sure after you do that to exit any command prompt you have open and reopen another one.
[ July 11, 2006: Message edited by: Keith Lynn ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by martin barfield:
...I even bought a PC because all of the instruction was PC based, I already have a Mac. I am ready to throw the PC out the window just about now. Can anyone help or point me in the right direction? ...

Yes, head towards an outside wall, locate a window, and toss the PC through it. (As you probably know, Java comes configured and ready to go on a Mac. )

But if you decide to keep struggling with a Windows machine...
  • Do not set a system CLASSPATH variable. If you have already set this, then remove it entirely.
  • For help setting the PATH variable, see step 5 in these Java installation instructions for Windows.


  • "We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
    sscce.org
    martin barfield
    Greenhorn

    Joined: Feb 13, 2006
    Posts: 9
    Thank you Ranch Hand Keith and Bartender Marc. I have been able to get to and edit the environment varibles but have been apprehensive as to what to do from there. It makes me nervous everytime I make system changes under the hood, I don't yet have a back-up drive to use as a safety net.

    Hopefully, the link Marc included helps. The Java site at Sun, while very thorough is a bear to navigate when you aren't sure what you are looking for. Who would have thunk that my issue was grouped into an installation notes page, I thought installtion was done when you downloaded and followed the prompts.

    Thanks again folks, I am sure I will be back.

    Martin
    Stan James
    (instanceof Sidekick)
    Ranch Hand

    Joined: Jan 29, 2003
    Posts: 8791
    I have a batch file that sets the PATH when I want to play with Java in a command window. That way I don't have to mess with system variables at all. Here's what SETJAVA5PATH.BAT looks like this. Let me know if the syntax is unfamiliar and needs explanation ...

    The "java -version" command on the end confirms that I got it right. Now I can run java and javac. Most of the time my command window experiments are very simple and don't need other jars. If you do need other jars or packages, you can set the classpath as an environment variable, or pass it to the java and javac commands as an argument.

    Here's a short tutorial on some of the issues around classpath and packages. See if it helps or confuses.


    A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
    marc weber
    Sheriff

    Joined: Aug 31, 2004
    Posts: 11343

    Originally posted by martin barfield:
    ... The Java site at Sun, while very thorough is a bear to navigate...

    True, but it's a lot better than it was several years ago!

    I know what you mean about messing with Windows settings, but this isn't too dangerous (like editing the Registry, for example). If you want a backup, you can simply copy what's already in the PATH value and save it as a simple text file. Just make sure you capture the entire string of values. Then if you really mess it up, just paste the text back in.

    Keep in mind that the PATH variable is just a list of different paths that the system tries from left to right when executing a command. It uses the first path in the list that works. So just leave whatever is already in the PATH variable where it is, and add your stuff to the right of that. In Windows, each item in the list must be separated by a semicolon, and make sure that you don't introduce any extra spaces.

    Note: In Sun's instructions, you need to replace <version> with whatever version you're using. So, for example, if you've downloaded Java 1.5 update 7, then replace "jdk-1_5_0_<version>" with "jdk-1_5_0_07".
    [ July 13, 2006: Message edited by: marc weber ]
    Vj Kamath
    Greenhorn

    Joined: Nov 19, 2004
    Posts: 15
    One more thing to remember.
    If you have the command prompt window BEFORE you set the PATH or CLASSPATH environment variable, then you will need to close and open the command prompt again.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Path and Classpath