0% found this document useful (0 votes)
47 views2 pages

Getting Started Workshop 1 in This Workshop, You'll Learn:: 1. Updating The PATH Environment Variable

This document provides instructions for setting up a Java development environment and writing a simple Java program that prints "Hello World". It describes updating the PATH environment variable to include the Java SDK bin directory. It then gives the code for a basic Java class with a main method that prints "Hello World" and steps for saving, compiling, and running the file. Finally, it prompts modifying the program to print out personal information.

Uploaded by

Thắng Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views2 pages

Getting Started Workshop 1 in This Workshop, You'll Learn:: 1. Updating The PATH Environment Variable

This document provides instructions for setting up a Java development environment and writing a simple Java program that prints "Hello World". It describes updating the PATH environment variable to include the Java SDK bin directory. It then gives the code for a basic Java class with a main method that prints "Hello World" and steps for saving, compiling, and running the file. Finally, it prompts modifying the program to print out personal information.

Uploaded by

Thắng Nguyễn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Getting Started

Workshop 1

In this workshop, you’ll learn:

 How to start a simple java application.

1. Updating the PATH Environment Variable


If you do not set the PATH variable, you need to specify the full path to the executable file every time
you run it, such as:

C:\> "C:\Program Files\Java\jdk1.8.0\bin\javac" MyClass.java


It is useful to set the PATH variable permanently so it will persist after rebooting.

To set the PATH variable permanently, add the full path of the jdk1.8.0\bin directory to


the PATH variable. Typically, this full path looks something like C:\Program Files\Java\jdk1.8.0\bin.
Set the PATH variable as follows on Microsoft Windows:

1. Click Start, then Control Panel, then System.


2. Click Advanced, then Environment Variables.
3. Add the location of the bin folder of the JDK installation to the PATH variable in System
Variables. The following is a typical value for the PATH variable:
4. C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0\bin

Note:

 The PATH environment variable is a series of directories separated by semicolons (;) and is not


case-sensitive. Microsoft Windows looks for programs in the PATH directories in order, from left
to right.
 You should only have one bin directory for a JDK in the path at a time. Those following the
first instance are ignored.
 If you are not sure where to add the JDK path, append it.
 The new path takes effect in each new command window you open after setting
the PATH variable.

2. Let us look at a simple code that would print the words Hello World.

public class MyFirstJavaProgram {


/* This is my first java program.

1
* This will print 'Hello World' as the output
*/
public static void main(String []args) {
System.out.println("Hello World"); // prints Hello World
}
}

Let's look at how to save the file, compile and run the program. Follow the steps given below:

 Open notepad and add the code as above.


 Save the file as: MyFirstJavaProgram.java.
 Open a command prompt window and go o the directory where you saved the class. Assume
it's C:\.
 Type ' javac MyFirstJavaProgram.java ' and press enter to compile your code. If there are no
errors in your code, the command prompt will take you to the next line (Assumption : The path
variable is set).
 Now, type ' java MyFirstJavaProgram ' to run your program.
 You will be able to see ' Hello World ' printed on the window.

C : > javac MyFirstJavaProgram.java


C : > java MyFirstJavaProgram
Hello World

3. Modify the above program and print out your information to screen, including: your full name,
your class name, your student id number and your age.

You might also like