Showing posts with label JDK. Show all posts
Showing posts with label JDK. Show all posts

Monday, July 5, 2010

What is java.home?


Target Audience: Beginners
When a java program runs, the java runtime environment (JRE- who runs any java program) sets some system properties for its own use and java.home is one of those system properties. The java.home is referencing the JRE home directory E.g: C:\Tools\jdk1.5.0_04\jre.

People tend to confuse with JAVA _HOME and java.home. They are different. JAVA _HOME is set by the user ( me or you) to reference JDK’s home directory. E,g: C:\Tools\jdk1.5.0_04\

Following are the system properties that java sets.
Key Description of Associated Value
java.version Java Runtime Environment version
java.vendor Java Runtime Environment vendor
java.vendor.url Java vendor URL
java.home Java installation directory
java.vm.specification.version Java Virtual Machine specification version
java.vm.specification.vendor Java Virtual Machine specification vendor
java.vm.specification.name Java Virtual Machine specification name
java.vm.version Java Virtual Machine implementation version
java.vm.vendor Java Virtual Machine implementation vendor
java.vm.name Java Virtual Machine implementation name
java.specification.version Java Runtime Environment specification version
java.specification.vendor Java Runtime Environment specification vendor
java.specification.name Java Runtime Environment specification name
java.class.version Java class format version number
java.class.path Java class path
java.library.path List of paths to search when loading libraries
java.io.tmpdir Default temp file path
java.compiler Name of JIT compiler to use
java.ext.dirs Path of extension directory or directories
os.name Operating system name
os.arch Operating system architecture
os.version Operating system version
file.separator File separator ("/" on UNIX)
path.separator Path separator (":" on UNIX)
line.separator Line separator ("\n" on UNIX)
user.name User's account name
user.home User's home directory
user.dir User's current working directory


public class SystemExample {
public static void main(String[] args) {
System.out.println("java.home :" + System.getProperty("java.home"));
System.out.println("java.vm.version :" + System.getProperty("java.vm.version"));
System.out.println("os.name :" + System.getProperty("os.name"));
System.out.println("os.version :" + System.getProperty("os.version"));
System.out.println("user.name :" + System.getProperty("user.name"));
}
}

The output will be similar to this

java.home :C:\Tools\jdk1.5.0_04\jre
java.vm.version :1.5.0_04-b05
os.name :Windows XP
os.version :5.1
user.name :kannan

Monday, June 28, 2010

Installing JDK on Windows


Target Audience: Beginners
If you want to write and run a program the you will need a development kit. which compiles your cource code and run the application. In Java, the tool is called Java Development KIT (JDK). This KIT contains the tools for compiling ,running, packaging and etc.

What should know before get into details: Difference between JRE and JDK
If you want to write and run a program the you will need a development kit. which compiles your cource code and run the application. In Java, the tool is called Java Development KIT (JDK). This JDK contains the tools for compiling ,running, packaging and etc.
JRE is the Java Runtime Environment. This contain the tool for running the Java application ( not for developing) . A user, other than a developer, who is going to run a Java program can use JRE. No need to get JDK as the user is not going to develop a program.

Where to download JDK?


SUN has a long list of versions of JDK that they have released so far. you can select the java version and the operating system on which you plan to use ( eg: JDK 1.5, Windows 32bit) .Download it to your local machine. if you can not find the one you want in the listing then look for the previous releases and download it. Once you download , execute the exe file with default option, it will install everything you.

Once it is installed, open the command prompt ( Start ->Run->Type 'cmd' and press 'OK') and type java. you will get a list of options for command 'java' and that indicates that you installed JDK successfully. If you do not see the options listed, then that means the Java path is not in the system environment and you need to set it.

How to set system environment variable
  • Let's assume it is installed in the folder "C:/tools/jdk1.5"
  • Right click on the My Computer icon on your desktop and select properties
  • Click the Advanced Tab
  • Click the Environment Variables button
  • Under System Variable, slect "Path" and click "edit"
  • Append ;C:/tools/jdk1.5/bin at the end of the value of "Path"
  • Click OK
  • Click Apply Change
Now open the command prompt again ( Start ->Run->Type 'cmd' and press 'OK') and type java. you will get a list of options for command 'java'.

Here is a video for installing JDK

Setting up JAVA_HOME System Variable in Windows


Target Audience: Beginners

The bellow instructions will lead you to set up JAVA_HOME environment variable in Windows . Know where JDK is installed. E.g: "C:/tools//jdk1.5"
  • Go to My computer
    For Windows XP : On Desktop or Start->My computer
    For Windows Vista : Start(Windows Icon)->Computer
  • Right click on My Computer icon and select properties
  • Click on Advanced Tab For Windows XP and 'Advance System Settings' task in Windows Vista
  • Click on Environment Variables button
  • Under System Variable, select New button
  • Enter the variable name "JAVA_HOME"
  • Enter the variable value as the install path for the Development Kit (E.g: C:/tools//jdk1.5)
  • Click OK
  • Click Apply Changes
You are done.