Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

15_COMPC_Sakshi Sharma_P1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Experiment 01 – Install Java

Learning Objective: Student should be able to install Java, set the environment variables and run
a simple java program
Tools: Java under Windows environment
Theory: Install Java, set the environment variables and run a simple java program
Installing Java:

Step 0: Un-Install Older Version(s) of JDK/JRE

If you have previously installed older version(s) of JDK/JRE, un-install ALL of them. Goto "Control
Panel" ⇒ (optional) "Programs" ⇒ "Programs and Features" ⇒ Un-install ALL programs begin with
"Java", such as "Java SE Development Kit ...", "Java SE Runtime ...", "Java X Update ...", and etc.
Step 1: Download JDK
1. Goto Java SE download site
@ http://www.oracle.com/technetwork/java/javase/downloads/index.html.
2. Under "Java Platform, Standard Edition" ⇒ "Java SE 11.0.{x}", where {x} denotes a fast
running security-update number ⇒ Click the "Oracle JDK" "Download" button.
3. Under "Java SE Development Kit 11.0.{x}" ⇒ Check "Accept License Agreement".
4. Choose the JDK for your operating system, i.e., "Windows". Download the "exe" installer (e.g.,
"jdk-11.0.{x}_windows-x64_bin.exe" - about 150MB).

Step 2: Install JDK


Run the downloaded installer (e.g., "jdk-11.0.{x}_windows-x64_bin.exe"), which installs
both the JDK and JRE.
By default, JDK is installed in directory "C:\Program Files\Java\jdk-11.0.{x}",
where {x} denotes the update number. Accept the defaults and follow the screen instructions to
install JDK.
Use your "File Explorer", navigate to "C:\Program Files\Java" to inspect the
sub-directories. Take note of your JDK installed directory, in particular, the update number {x},
which you will need in the next step.
In the following diagram, the JDK installed directory is "C:\Program
Files\Java\jdk-11.0.1", where {x}=1.
refer to the JDK installed directory as <JAVA_HOME>, hereafter, in this theory.

Step 3: Setting Environment Variables


Windows' Command Prompt (CMD) searches the current directory and the directories listed in
the PATH environment variable (or system variable) for executable programs. JDK's programs (such
as Java compiler "javac.exe" and Java runtime "java.exe") reside in the sub-directory "bin"
of the JDK installed directory. You need to include JDK's "bin" in the PATH to run the JDK
programs.
To edit the PATH environment variable in Windows 10:
1. Launch "Control Panel" ⇒ (Optional) "System and Security" ⇒ "System" ⇒ Click "Advanced
system settings" on the left pane.
2. Switch to "Advanced" tab ⇒ Click "Environment Variables" button.
3. Under "System Variables" (the bottom pane), scroll down to select variable "Path" ⇒ Click
"Edit...".
4. For Newer Windows 10:
You shall see a TABLE listing all the existing PATH entries (if not, goto next step). Click
"New" ⇒ Click "Browse" and navigate to your JDK's "bin" directory, i.e., "c:\Program
Files\Java\jdk-11.0.{x}\bin", where {x} is your installation update number ⇒ Select "Move Up"
to move this entry all the way to the TOP.
Skip the next step.
5. For Older Windows 10:

In "Variable value" field, APPEND "c:\Program Files\Java\jdk-11.0.{x}\bin" (where {x} is your


installation update number) IN FRONT of all the existing directories, followed by a semi-colon
(;)to separate the JDK's bin directory from the rest of the existing directories

6. Variable name : PATH


Variable value :c:\Program Files\Java\jdk-11.0.{x}\bin;[do not delete exiting entries...]

Step 4: Verify the JDK Installation


Launch a CMD via one of the following means:
1. Click "Search" button ⇒ Enter "cmd" ⇒ Choose "Command Prompt", or
2. Right-click "Start" button ⇒ run... ⇒ enter "cmd", or
3. Click "Start" button ⇒ Windows System ⇒ Command Prompt
Issue the following commands to verify your JDK installation:
1. Issue "path" command to list the contents of the PATH environment variable. Check to make
sure that your JDK's "bin" is listed in the PATH.
2. path

PATH= ;c:\Program Files\Java\jdk-11.0.{x}\bin

3. Issue the following commands to verify that JDK/JRE are properly installed and display their
version:

// Display the JDK version


javac -version
javac 11.0.1

// Display the JRE version


java -version
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

PROGRAM :

importjava.util.*;
public class newClass
{
int u=5;
public static void main(String [] args)
{
newClass q=new newClass();
System.out.println(q.u);
}
}

Output :
5

Screenshot of my Program:
Learning Outcomes: The student should have the ability to
LO1: identify problems during installation of Java.
LO2: Set the environmental variables
LO3: Run sample program in java.
LO4: Correct problems while execution of program.
Course Outcomes:Upon completion of the course students will be able to install java and
execute programs.
Conclusion: In this experiment, we understood how to install java in our system and learned
about JVM, JDK, and IDE. Following all the steps we successfully installed java and checked
the version we have installed. We have run one program and the screenshot of same is
attached.

For Faculty Use


Correction Formative Timely completion Attendance /
Parameters Assessment of Practical [ 40%] Learning
[40%] Attitude [20%]
Marks
Obtained

You might also like