[Jon's Java class] A simple Java Program.

User avatar
by Jon™ · 3 posts
8 years ago
Posted 8 years ago · Author
Once you are done with the Introduction, let's move on and create a simple Java program.

I dislike the famous "Hello World!" program and frankly got tired of it being spammed all over the internet so we won't go for it. But instead, we will take a revolutionary step by starting by creating a "Jon is awesome!" program.

Just write down the following code in Editplus or Notepad++ as it is and I will explain bits and pieces of it as we progress.

Code
class Jonisawesome{

public static void main(String[] args)
{

System.out.println("Jon is awesome!");

}

}


Once done, save the file in a directory with the name "Jonisawesome.java". It is important that the file should end with .java extension and the name of the file should be same as the class name, which in our case is "Jonisawesome".

Running your Java file!

Once you have saved your file;

Step 1: Open up the command prompt/cmd.

Step 2: Change the location of the cmd prompt that of which your program's stored in.

( This can be done by using "cd <-- Paste the location -->" )

Then type in the following;

Code
javac <--Insert the location of Jonisawesome.java --> 


It wil compile and create a .class file. Now if you check the directory, it should contain a .class file by the name Jonisawesome.class.

Step 3: Type in

Code
 java Jonisawesome 
and hit enter.


If everything goes right you should have something like this. If you haven't figured out how to change directories on cmd, check the below screen.

Image Lightbox

Explanation:

Here is a brief explanation of the program. I won't go into details here as you need to learn a few more concepts before going into the details. But no worries, we will learn it in time!

-> In the above program, Jonisawesome is a class.

You can create your own class by using the keyword "class".

-> Inside the class, we used a method "public static void main(String[] args)". For now, just remember that without this method, no class will compile. I will explain what this is about when it's time.

-> System.out.println() is the function used to display the output in the monitor. Whatever you write inside the " " in the System.out.println("") function will be displayed in the monitor.

In our case, it was "Jon is awesome!".

Assignment:

If you have any doubts, post below and I will clear it for you.

Once done, create a Java program that says Yournamehere is awesome!
Posted 8 years ago
Thanks for these tutorials, I hope you can post more of them.
Posted 8 years ago · Author
I am a bit tied up iRL having interviews on a daily basis but I haven't forgotten about this certainly!
From next week, I'll start with more basic programming stuffs, OOPs, File Handling, Exception Handling, Collections and Threads.

Then if possible I'll go on with JDBC, Servelets, JSP, Hibernate and Springs.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts