• Post Reply Bookmark Topic Watch Topic
  • New Topic

PATH environment variable  RSS feed

 
Neeraja Murali
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am a newbie in java and have purchased a book for the same purpose. I have installed the Java 1.5 SDK. I want to know how to go about adding an entry to the "PATH environment variable".
[ June 08, 2006: Message edited by: Bear Bibeault ]
 
Amit Sethi
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"steps for registering path variable"

click start
then go to control pannel
double click system ikn.
select advance.
click environment variable.
press new & put path.
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Declaring the CLASSPATH environment variable depends on the operating system you're working on, and there is more than a way to do it.

For instance, you can always define the variable in the command line before executing the code.

Under Windows you can do this with the command SET, and test it with the command ECHO, enclose your environment variable within % to see its value.

> SET CLASSPATH = .;c:\jakarta\commons\lang.jar
> ECHO %CLASSPATH%

Under Linux, you can do something similar. (I am working on windows now, so if I make a mistake, please correct me).

> CLASSPATH = .:/home/Anakin/libs/jakarta/commons/lang.jar
> export CLASSPATH

Note as under Windows every element in the CLASSPATH should be separated with ";" while under Linux there are separated with ":". Always include the current path (.) in your CLASSPATH.

Now, if you would like to make this CLASSPATH variable persistant...

Under Windows:
  • Make right click on your My PC icon
  • Choose properties
  • Select Advanced Tab
  • Click Environment Variable
  • In the Section Environment Variables for your User
  • Declare a new variable named CLASSPATH with all your path elements separated by semicolon.



  • Under Linux it depends on your distribution. On Fedora Core you can declared in the etc/profile file. On Ubuntu you can declare it in the ~/.bash_profile file. To make this variable public to all user you could declare it in the /etc/ENVIRONMENT file, also

    There is another option. Instead of declaring your CLASSPATH in a variable, define it every time your run your java application using the classpath flag of the java application launcher.

    For instance

    > java -classpath .:/home/Obi-Wan/jedis.jar:/usr/lib/java/other.jar run.my.App

    Remember to separte your classpath elements with semicolon under Windows and with a colon under Linux.

    I also recommend you to read this article about setting the class path

    Setting the class path under Windows

    Setting the class path under Linux/Solaris

    I hope this helps!
    [ June 08, 2006: Message edited by: Edwin Dalorzo ]
     
    Joanne Neal
    Rancher
    Posts: 3742
    16
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Normally you wait for a question to be asked before giving an answer Edwin, but I guess it's reasonable to assume that once the OP has got their PATH variable set correctly, they will want to know how to set the CLASSPATH
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 66207
    151
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Just so newbies don't get confused, PATH and CLASSPATH have nothing to do with each other.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!