Search

Class path in Java

Q. How to set classpath for Java in different OS?

Ans.

In Windows

1. Select Start -> Control Panel -> System -> Advanced -> Environment Variables -> System Variables -> CLASSPATH.
2. If the Classpath variable exists, prepend .;C:\programfiles\JDK1.7\bin to the beginning of the CLASSPATH varible.
3. If the CLASSPATH variable does not exist, select New. Type CLASSPATH for the variable name and .;C:\programfiles\JDK1.7\bin for the variable value.
4. Click OK three times.

In Ubuntu

1. In terminal execute
  $ sudo gedit /etc/environment
2. Enter as below in editor.
export JAVA_HOME="/usr/lib/JDK1.7";
3. Now add JAVA_HOME to path as shown below.
export PATH="$JAVA_HOME/bin:$PATH"

No comments: