Java is a programming language designed by Sun
Microsystems and offers many benefits to the professional programmer and
application developer. Java is a byte-compiled language and is completely
portable. You can run the same Java program on a wide range of operating
systems. Java is often faster than interpreted languages (e.g. TCL, Perl) but
slower than fully compiled languages (C, C++).
Because of its portability, Java and the World Wide Web
make an excellent match. With a Java-enabled browser, Web designers can embed
applets into their Web content. The applets are downloaded over the Internet
with the context of the Web document and are then executed on the local
computer. Applets can add interactivity, animations, multimedia, or database
interfaces to an otherwise dull and listless Web site.
Programming with the Java Virtual Machine
The Java Virtual Machine is at the heart of the Java
programming language. In fact, you cannot run a Java class or Java applet
without also running an implementation of the Java Virtual Machine. Internet
browsers Netscape and MSIE each include an implementation of the Java Virtual
Machine (usually referred to as a Java runtime environment or JRE).
The Java Virtual Machine is the engine that actually
executes a Java program. When a Java program is run, the instructions are not
executed directly by the hardware of the local system, instead an interpreter
or "virtual processor" walks through the instructions step-by-step
and implements the action the instruction represents. This may seem abstract,
but it actually provides a level of protection between your computer and the
software you run on your computer. With a Java Virtual Machine, it is very easy
to insert protections that prevent a program from performing malicious acts,
such as deleting files on your disk or corrupting memory.
Using Java on the VPS v2 Virtual Server
There are several Java tools currently available that are
compatible with version 1.0.2 of the Java specification. The 1.0.2
specification is supported by all Java-enabled browsers. Java 1.1.8 is
installed on your VPS v2 Virtual Server.
Decide whether to set the filepath where Java needs to
look in order to run, on a global basis or on an individual basis.
(Global)
% vi /etc/profile add:
PATH =/usr/local/jdk1.1.8/bin/
export PATH
(Individual using csh, tcsh, or zsh)
% vi /usr/local/.cshrc, .tcshrc, or.zshrc
Move to the end of the “set
path” line and type:
% set path = /usr/local/jdk1.1.8/bin
(Individual using sh, bash, or ksh)
% vi /usr/local/.shrc, .bashrc, or.kshrc
Move to the end of the “set
path” line and type:
export PATH = $PATH=:/usr/local/jdk1.1.8/bin
Java tools
Java tools on your server are the Java Bytecode compiler
and Java Virtual Machine with the “just in time” (JIT) compiler.
Java Bytecode Compiler (javac)
javac converts Java source code (.java files) into .class
files that contain the Java bytecode for the class. For example:
% javac Test.java
where Test.java is a Java source code file. The resulting
class file can then be embedded into Web content. If you have a Java-enabled
browser, you can check out the example applet yourself.
Java Virtual Machine (Interpreter) and "Just-in-Time" Compiler
(java)
The Java Virtual Machine is an interpreter for Java bytecode.
This also includes a "Just-In-Time" (JIT) code generator. JIT is a
technique for speeding up the execution of interpreted programs. The idea is
that, just before a method is run for the first time, the machine-independent
Java bytecode for the method is converted into native machine code which can
then be executed by the computer directly. The JIT code generator greatly
increases the speed of interpreted bytecode to nearly the speed of compiled
code. For example:
% java Test
This executes the Test.class bytecode compiled with the javac
bytecode compiler (see above). (The Java Virtual Machine installed on the
servers is java_x 1.18.)
|