Sie sind auf Seite 1von 6

OOP Practice / MC

Practice Module 1
Introduction to Object Oriented Programming

1. Objectives
Students have ability to use netbeans as an editor and execute simple Java program.

2. Basic Theory
Java is flexible language programming that we can say that it has motto as WORA (Write Once
Run Anywhere). We can develop in any platform and run it in any other platform. First off all,
we can do this steps before having our first program by Java.

 Check the PATH first, by click the Start Menu than right click in the My Computer and
choose Properties.

 Choose Advanced System Settings

https://introcs.cs.princeton.edu/java/15inout/windows-cmd.html Page 1
OOP Practice / MC

 Click Environment Variables button

 We can see C:\Program Files\Java\jdk1.8.0_121\bin; to the beginning of the PATH


variable.

 If not yet then do the following steps :

 Click New button

https://introcs.cs.princeton.edu/java/15inout/windows-cmd.html Page 2
OOP Practice / MC

 Fill the variable value like in the image, but adjust to where you install Java then
click OK twice.

 Second step is opening the Command Prompt by click Start Menu – All Programs –
Accessories – Command Prompt or Start – Run – type cmd then click OK.

https://introcs.cs.princeton.edu/java/15inout/windows-cmd.html Page 3
OOP Practice / MC

3. Practice Task
1. Create your first simple program.
Open your notepad, then type this code :

Save your code to your directory with name MyFirstJava.java, choose All Files as shown
below :

To run the program:


Use command prompt, go to your directory as shown below :

Type D: then enter.

https://introcs.cs.princeton.edu/java/15inout/windows-cmd.html Page 4
OOP Practice / MC

Type cd P1_NIM then enter

Then compile your java file by type javac MyFirstJava.java on your command prompt
then enter.

If there is no error there, then we could execute the file by type java MyFirstJava then
enter and the output should be shown below :

Congratulations, your first program is successful.

https://introcs.cs.princeton.edu/java/15inout/windows-cmd.html Page 5
OOP Practice / MC

2. Base on the steps above, in the same directory, create class mydata that are show your
own data.
For example
Name : Adi Santoso
NIM : 123456789
Address : Jl. Ahmad Yani No. 1 Batam Centre
No HP : 08123456789

3. What happens if the classname of the program "mydata" was changed to "data"? Write down
your analysis of the program. Draw conclusions from what you have learned from this lab.

Save your report with name P1_NIM.doc and your java files to your directory with name P1_NIM
in zip.

https://introcs.cs.princeton.edu/java/15inout/windows-cmd.html Page 6

Das könnte Ihnen auch gefallen