Main Menu

friends

Banner

Latest articles

NASA: 2012: Beginning of the End or Why the World Won't End?
18/11/2009 | mad mad mod

  NASA F.A.Q. about 2012: http://www.nasa.gov/topics/earth/features/2012.html     


Install PHP for Apache (Fedora 12)
31/03/2010 | mad mad mod

This article describes how to install PHP for Apache on Linux (Fedora 12).
 Step 1: Install PHP  run the following command as root:

# yum install php


 Setting up Install Process
Resolving Depende [ ... ]


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