How to set the environment variables for java in windows (the classpath )
Join them; it only takes a minute:
|
Java SE Development Kit 8u112 on a 64-bit Windows 7 or Windows 8Set the following user environment variables (== environment variables of type user variables)
Notice that these environment variables are derived from the "root" environment variable There is a blogpost explaining the rationale behind all these environment variables. Optional recommendations
|
|||||||||||||||||||||
|
|
In Windows inorder to set Step 1 : Right Click on MyComputer and click on properties . Step 2 : Click on Advanced tab |
|
|
Nice explanation. One small thing in step 6: Don't type
$java or $javac, but just java or javac.
– Jesper
Nov 4 '09 at 9:43
|
||
|
And note that you must add the JDK bin directory to the
PATH environment variable; just setting JAVA_HOME is not enough.
– Jesper
Nov 4 '09 at 9:44
|
||
|
yeah sorry since im a Linux lover . i missed it will change it , Thanks
– Srinivas M.V.
Nov 4 '09 at 9:44
|
||
|
1. use backslashes in WINDOWS 2. dont start any path with ".;" 3. add %JAVA_HOME%\bin to the path, like that you can later change the java_home without having to change the path
– raudi
Feb 12 '14 at 20:23
|
||
|
|
The JDK installation instructions explain exactly how to set the Normally you should not set the |
|||||
|
|
In Windows 7, right-click on Computer -> Properties -> Advanced system settings; then in the Advanced tab, click Environment Variables... -> System variables -> New.... Give the new system variable the name Then select the If there are any issues executing programs, try these steps. If you don't see similar results, you may need to reinstall JDK. Open a Windows command prompt (Windows key + R -> enter
You will see something like this:
Then check the following:
You will see something like this:
|
||||
|
|
|
Under Windows: http://vlaurie.com/computers2/Articles/environment.htm Under Linux: http://lowfatlinux.com/linux-environment-variables.html And of course, you can retrieve them from Java using:
|
|||
|
|
|
Keep in mind that the In case of JAR files, the classpath is to be definied as In case of an IDE, you have the so-called 'build path' which is basically the classpath which is used at both compiletime and runtime. To add external libraries you usually drop the JAR file in a (either precreated by IDE or custom created) |
|||||||||
|
|
I am going to explain here by pictures for Windows 7. Please follow the following steps: Step 1: Go to "Start" and get into the "My Computer" properties
Step 2: Go to "Advance System Setting" and click on it.
Step 3: Go to "Start" and get into the "My Computer" properties
Step 4: The dialog for Environment variable will open like this:
Step 5: Go to path and click on edit.
Step 6: Put the path of your JDK wherever it resides up to bin like you can see in the picture. Also add path from your sdk of Android up to the Platform Tools:
|
|||
|
|
|
In programming context you can execute SET command (SET classpath=c:\java) or Right click on your computer > properties > advanced > environment variables. In a batch file you can use
|
|||||||||
|
|
For Windows 7 users: Right-click on My Computer, select Properties; Advanced; System Settings; Advanced; Environment Variables. Then find PATH in the second box and set the variable like in the picture below.
|
||||
|
|
|
Set java Environment variable in Centos / Linux /home/ vi .bashrc export JAVA_HOME=/opt/oracle/product/java/jdk1.8.0_45 export PATH=$JAVA_HOME/bin:$PATH java -version |
|||||
|
|
For deployment better to set up classpath exactly and keep environment clear. Or at *.bat (the same for linux, but with correct variables symbols):
Or at command line or *.bat (for *.sh too) if classpath id not very long:
|
|||
|
|
|
For Windows:
|
||||
|
|
|
To set java path There are two ways to set java path A. Temporary
B. Permanent
|
|||
|
|
|
Using wildcards in java classpath Wild cards were introduced from Java 6 . Class path entries can contain the basename wildcard character *, which is considered equivalent to specifying a list of all the files in the directory with the extension .jar or .JAR.
Where %MAINCLASS% is the class containing your main method. More on...Path and ClassPath Rj |
|||
|
|
protected by Community♦ Jan 21 at 16:53
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?










