Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Path and Classpath

 
martin barfield
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  •  
    martin barfield
    Greenhorn
    Posts: 9
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 8791
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    marc weber
    Sheriff
    Posts: 11343
    Java Mac Safari
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 15
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic