Main Menu

friends

Latest articles

backup MBR (master boot record) with dd
13/04/2010 | mad mad mod

The first 512 bytes of a partitioned storage device is called the MBR (master boot record). The main reason why I think you should backup the MBR is because it contains the disks primary partition tab [ ... ]


No Sound from speaker or headphones on my HTC Desire HD with Android OS
03/03/2011 | mad mad mod

I have a HTC Desire HD mobile phone and recently I stopped getting sound out of the speakers or headphones. I've checked everything and the only thing that fixed the problem was removing the battery f [ ... ]


Other Articles
Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 

Designed by:
SiteGround web hosting Joomla Templates
Hello World in java E-mail
programming

This article describes how to write, compile and execute a "Hello World" program in java on Linux (Fedora).

 

1. the prerequisites

 

2. write the code


open an empty file with a text editor (e.g. vi):


# vi HelloWorld.java



now write the following code into the sourcefile:

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



save the file and exit vi with ":wq + enter"

 

important: the source file must have the same name as the public class (HelloWorld.java)

 

explanation


public class HelloWorld {

}

our "main" class is called HelloWorld. public indicates that the class can be used by any program or user.

 

public static void main( String args[] ) {

}

The main method ist where the execution of the class starts. void indicates that the method does not return any value.

 


System.out.println( "Hello World!" );

This prints out the string "Hello World!"

 

 

3. compile into bytecode



# javac HelloWorld.java




This produces an file called "HelloWorld.class".



4. run the program


you can now execute the bytecode with:


# java HelloWorld
Hello World!

 

 

 

Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:D:angry::angry-red::evil::idea::love::x:no-comments::ooo::pirate::?::(
:sleep::););)):0
Security
Please input the anti-spam code that you can read in the image.

!joomlacomment 4.0 Copyright (C) 2009 Compojoom.com . All rights reserved."

 
mad mad mod, Powered by Joomla! and designed by SiteGround web hosting