1. Home
  2. Computing & Technology
  3. Linux

Linux Newbie Administrator Guide

From

8.2.12 Java

javac

java

The Java language compiler and interpreter. Under Linux, both javac and java are actually scripts which call kaffe with appropriate options (try cat /usr/bin/java).

A trivial example for a java "standalone" program. I use my favourite text editor, e.g. kate (in X terminal) to type in the following java code:

/* Comments are marked like in C++

* A java class to display "Hello World"

*/

class HelloWorldApp {

public static void main(String[] args) {

System.out.println("Hello World.") ; // Print "Hello World." followed by a newline

}

}

I save this into a file named try_java.java. Now, I can compile it using:

javac try_java.java

This creates a file called HelloWorldApp.class which contains the "bytecode" (semi-compiled code which requires an interpreter to run). I can run it on the command line using:

java HelloWorldApp

For an example on how to embed a simple java applet into an html web page, have a look at http://java.sun.com/docs/books/tutorial/getStarted/cupojava/unix.html from which my java "standalone" program was borrowed.

* License

* Linux Newbie Administrator Guide Index

Explore Linux
About.com Special Features

The Best Web Trends of the Decade

A look back at the best innovations, ideas and technologies over the last 10 years, More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. Linux
  4. Linux Documentation
  5. Newbie Administrator Guide
  6. Linux Newbie Administrator Guide - 8.2 Simple Programming under Linux

©2009 About.com, a part of The New York Times Company.

All rights reserved.