Sicktier Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

My First Program in Java (Hello World!)

View previous topic View next topic Go down

My First Program in Java (Hello World!) Empty My First Program in Java (Hello World!)

Post by Mases Wed Jan 14, 2015 5:54 pm

Yes, yes. I'm finally taking some programming classes and expanding my knowledge about computers, programming, and engineering. I wanted to post my first program here for everyone to see, and hopefully run it as well on their computers with me. First, you need a java compiler or a java machine installed on your operating system. If you have a Mac, OS X comes with all that already, and this tutorial was made for that.

First, open your Terminal. We will use the OS X Terminal to compile and execute our program today. From their, you want to type the following:

Code:
mkdir bin

Then

Code:
cd bin

Then

Code:
vi HelloWorld.java

What we did here was create a new folder for our project to separate our files from the user-directory level. Then, we moved our Terminal to the new folder by using the command cd. Vi is the editor built in the terminal of the OS X. We created a new text editor file, and we declared it HelloWorld.java. In there you press the key (i) and you type:

Code:
public class HelloWord{
     public static void main(String [] args){
          System.out.println("Hello World!");
     }
}

One done, press ESC, and hold shift and press the key Z twice to save and exit the editor. Now type:

Code:
javac HelloWorld.java

to compile your text file, and then finally type:

Code:
java HelloWorld

to see the results!
Mases
Mases

My First Program in Java (Hello World!) Barcod11

Gender : Male

Posts : 23

Join date : 2014-02-20

Respect Bar : My First Program in Java (Hello World!) Empty


https://sicktier.board-directory.net

Back to top Go down

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum