CORE JAVA

ProwessApps Learning Portal

Java Environment Setup


  • In order to compile and run your java source code first of all you have to install and configure the java compiler and run time environment in your system.

  • For this Java provides jdk (Java Development Kit).

  • You can download JDK from internet.
    Download the JDK according to your system configuration (32 bit or 64 bit).

  • After downloading install it, installation is as simple as other software.

  • After installation, set the path of java compiler.

  • Path setting process varies from platform to platform e.g. windows,linux etc. .

Path Setting on Windows OS :

There are the following steps to set the path :

STEP 1: First check the JDK installation directory and copy the path.
By default it will be at the location
"C:\Program Files\Java\jdk1.8.0_25\bin";
Copy this path

prowessapps.com


STEP 2: Now Right click on Computer goto properties.
prowessapps.com


STEP 3: The above step will open a new window, click on 'Advanced system settings' .

prowessapps.com


STEP 4: The above step will open a new window, click on 'Environment Variables...' button.

prowessapps.com


STEP 5: The above step will open a new window as shown below

prowessapps.com
In new User Variable window, type path in variable name box.
And paste the path that you have copied in Step1 into variable value box.
Now click on OK button.
NOTE: IF path variable already exist then inplace of "New..." button click on "Edit.." button.
And paste the copied path from "Step1" at the end of 'variable value' box followed by semicolon ' ; '.


STEP 6: To check whether the path is successful set or not, open the command prompt, and type the following command.
javac -version
To open command prompt Press +r , type "cmd" and press OK button.

prowessapps.com
If the path is successful set it will show you the version like this:

prowessapps.com


Path Setting on Solaris and Linux:

To find out if the path is properly set, execute:

% java -version

This will print the version of the java tool, if it can find it.
If the version is old or you get the error java: Command not found, then the path is not properly set.

To set the path permanently, set the path in your startup file.

For C shell (csh), edit the startup file (~/.cshrc):

set path=(/usr/local/jdk1.7.0/bin $path)

For bash, edit the startup file (~/.bashrc):

PATH=/usr/local/jdk1.7.0/bin:$PATH

export PATH

For sh, edit the profile file (~/.profile):
PATH=/usr/local/jdk1.7.0/bin:$PATH
export PATH

Then load the startup file and verify that the path is set by repeating the java command:

For C shell (csh):

% source ~/.cshrc
% java -version

For bash, or sh:

% . /.profile
% java -version


Path Setting on Mac OS x:

To run a different version of Java, either specify the full path, or use the java_home tool:

% /usr/libexec/java_home -v 1.8.0_73 --exec javac -version






advertisement