Basic Environment Setup

Java Environment setup:-

 

Windows 7

 

1.    Select Computer from the Start menu

 

 

2.    Choose System Properties from the context menu

 

 

3.    Click Advanced system settings > Advanced tab

 

 

4.    Click on Environment Variables, under System Variables, find PATH, and click on it.

 

 

5.    In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.

 

 

6.    Reopen Command prompt window, and run your java code.

 

 

Now your set up has been completed u may now setup your preferred IDE

 

Configure Java environment on Linux

After installing jdk or jre  on Linux/Unix, you may still need to do some configuration to get Java ready for running or compiling Java programs. The following instruction will guide you through the process of setting up JDK for software development. JRE can be configured similarly.

JDK is usually installed into /usr/java directory. Create a symbolic link to the installation directory. That way makes it easier to switch between different Java versions that you may have just by redirecting the link to the appropriate target directory.

# ln -s /usr/java/jdk1.5.0 /usr/java/j2se

Create a java.sh file in /etc/profile.d directory with content as follows:

#!/bin/bash
           
JAVA_HOME=/usr/java/j2se
JAVA_FONTS=/usr/share/fonts/truetype
ANT_HOME=/usr/share/ant
                       
PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
                                       
export PATH JAVA_HOME JAVA_FONTS ANT_HOME
export CLASSPATH=.

The file contains various shell commands which set and export necessary environment variables for Java. It assumes Apache ant and Unicode TrueType fonts have been installed in appropriate directories. Ant is a tool widely used in building and executing Java applications. Shell settings from configuration files in the /etc/profile.d directory are gathered by /ect/profile during login, setting up user environment information for every user.

Assign execute permissions:

# chmod 755 java.sh

You can verify the availability of Java to users after login by:

# java -version