Share
Explore

Setting up your First Java Program


Technical Stream: Java Program Plus Database to model the Model the Monopoly Game


Write some Java
Text Editor and a Command Prompt


First: Learn to work with File System, Files and also the Command Terminal.
In a day or two I will post a Video Tutorial on working with the File System and The Command Terminal.


For now, just follow me:


1. Let's open a Text Editor.
2. Save your File in the File System - Save the file as Monopoly.java
3. Make a DIRECTORY to save your Java Code File into.

image.png
image.png
image.png

image.png


image.png

image.png

How do we “run” / execute our Java Program

image.png


image.png


Now we are ready to “run” our Program:
java.exe NameOfClassFile
This does WHAT?

image.png
image.png
public class MonopolyGame{

// comments : leave little reminders to yourself
// comments are ignored by the Java Compiler:
// Write a Hello World Program

// Syntax => is the way we write words in our program
// For now: just copy and the understanding will come later

// How to "run" or "execute" our Java Program?
// Open Command Terminal cmd
// Navigate or go to the Directory which this File is in

public static void main(String [] args){
Calculator c = new Calculator();
System.out.println(c.Add(2,2));
}
}

// let's make a Calculator

class Calculator{
public int Add(int a, int b){
return a + b;
}
}
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.