Wednesday, February 29, 2012
Your First Java Program: Hello, World!
For your first Java program we are going to code the world famous "Hello, World!" program. If you're going to code in other languages I guarantee you'll see this same program many times.
To start, open up your text editor and type the code in exactly how you see it to the right.
Save it as HelloWorld.java
The filename must always be what is after public class.
Now you need to compile and run your program. Open your command prompt and point it to where you saved your program. I save mine on my desktop so I typed: cd Desktop (Note: I am using Linux so mine will probably look different than yours.)
Now you can compile your program by typing: javac HelloWorld.java
After it is compiled your computer should have made a new file in the same folder as your program but instead of a .java file it will be a .class file. That is your compiled program.
You can now run your program by typing: java HelloWorld
Congratulations on making your first Java program!
For more tutorials please subscribe by entering your email over there -->
or bookmark us and comeback daily for a new lesson.
If you have any problems comment below and I will do my best to help you out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment