eHow launches Android app: Get the best of eHow on the go.

How To

How To Write Java Programs

Contributor
By Jackson Lewis
eHow Contributing Writer
(0 Ratings)
Java Programming Language Logo
Java Programming Language Logo
WIkimedia Commons by Sun Microsystems

Java is an object-oriented programming language originally developed and released by Sun Microsystems in the mid-1990s. Java was developed from the start as an object-oriented language that could be written once and run on any operating system without modification. Unlike Java's programming language predecessors C and C++, Java is able to be run as an applet embedded in a web page, as well as a standalone application. Because all programming in Java is object oriented, beginning programmers are typically able to create more complex applications in a faster time frame than with other programs.

From Quick Guide: Writing Computer Programs
Difficulty: Moderately Easy
Instructions
  1. Step 1

    Setup a Java development environment on your computer by downloading the latest Java software developer's kit from Sun Microsystems.

  2. Step 2

    Open your text editor for composing the Java program. Save the file with the name myFirstJavaProgram.java.

  3. Step 3

    Type the following code into the text editor and save the file.
    class myFirstJavaProgram
    {
    public static void main (String[] args)
    {
    System.out.println("This is my first Java application! Don't forget to end the line with a semi-colon!);
    } // end of main
    }// end of class

  4. Step 4

    Compile the Java class into byte code. To do this, open the command prompt on a Windows computer or the command line in Unix. Change the directory to that which the Java file is saved, and type javac myFirstJavaProgram.java. This command will convert the Java source code to byte code.

  5. Step 5

    Invoke the Java interpreter on the command line by typing java myFirstJavaProgram. This command will invoke the Java Virtual Machine and run the program. The command line will display the program output, "This is my first Java application! Don't forget to end the line with a semi-colon!".

Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

eHow Computers
eHow_eHow Technology and Electronics