Wednesday 2 March 2016

JDK Environment

After you install Java 7, the core java runtime command may appear in your path (available to run) automatically. However, many of the other commands provided with the JDK may not be available unless you add the Java bin directory to your execution path. The following commands show how to do this on Mac OS X and Windows. You will, of course, have to change the path to match the version of Java you have installed.

 # Mac OS X  
 export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home  
 export PATH=$PATH:$JAVA_HOME/bin  
 # Windows  
 set JAVA_HOME=c:\Program Files\Java\jdk1.7.0_09  
 set PATH=%PATH%;%JAVA_HOME%\bin  
On Mac OS X, the situation may be more confusing because recent versions ship with “stubs” for the Java commands installed. If you attempt to run one of these commands, the OS will prompt you to download Java at that time. As of the time of this writing, Mac OS X still ships with Java version 6, so you will need to download version 7 and set up your environment as just shown. When in doubt, your go-to test for determining which version of the tools you are using is to use the -version flag on the java and javac commands:
 java -version  
 # java version "1.7.0_07"  
 # Java(TM) SE Runtime Environment (build 1.7.0_07-b10)  
 # Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)  
 javac -version  
 # javac 1.7.0_07  

0 comments:

Post a Comment