Java

Introduction

Java is a general-purpose, concurrent, class-based, object-oriented computer programming language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java applications are typically compiled to bytecode (class file) that can run on any Java virtual machine (JVM) regardless of computer architecture. Java is, as of 2012, one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users. Java was originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them.

The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1991 and first released in 1995. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java and GNU Classpath.

Usage

Compute Systems Invocation Version(s)
Red Hat Linux (64-bit)

% /util/bin/javac filename.java
% /util/bin/java filename

9.0.4 (default)

Examples

  1. HelloWorld. Compile and run HelloWorld.java, attached below:
    
    % javac HelloWorld.java
    % java HelloWorld
    
    
  2. MathLibraryExample. Compile and run MathLibraryExample.java, attached below:
    
    % javac MathLibraryExample.java
    % java MathLibraryExample
    
    

Notes

  1. Find out which version of java you're running:
    
    % java -version
    
    or
    
    % java -fullversion
    
    
  2. Even if you're using the default /usr/bin/java, you might still find the documentation in /usr/j2se/docs/ useful.
  3. CLASSPATH. If you need to set your CLASSPATH environment variable, make sure that the classes.zip that you use is the one that corresponds to the java interpreter that you're using. But note that Java 1.2 does not require its main classes file to be in your CLASSPATH. For example, if you're using the Java from /util/jdk1.1.8/, then the classes.zip to use is /util/jdk1.1.8/lib/classes.zip. If you have a classes.zip from a Java version other than the java that you're using, bad things will happen, even if they're both the same "version".

References

  1. http://en.wikipedia.org/wiki/Java_%28programming_language%29
  2. http://www.java.com/en/ (Java home and download site)
  3. http://www.oracle.com/technetwork/java/index.html (Java developers' homepage)
  4. http://download.oracle.com/javase/tutorial/ (The Java Tutorials)
  5. http://www.oracle.com/technetwork/topics/newtojava/overview/index.html (New to Java Programming Center)
  6. http://www.java.com/en/download/help/testvm.xml (Test Your Java Virtual Machine (JVM))
  7. http://www.cafeaulait.org/course/week4/40.html (Examples of java.lang.Math Methods)
AttachmentSize
HelloWorld.java121 bytes
MathLibraryExample.java4.71 KB
Echo.java1.46 KB