13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.4 The Java Runtime Engine1215.4THE JAVA RUNTIME ENGINEYou can download and install just the software required to run Java applicati<strong>on</strong>swithout the development tools. This is known as the Java 2 Runtime Editi<strong>on</strong>.5.4.1 The BasicsYou run a Java program by invoking the java command. Usually, the argumentto the command is a class name. That class is loaded, and its main() methodis run.Remember, this is not a filename, but a class name! The rest of the command-linearguments that follow the class name are passed as an array ofStrings to the main() method of the named class. Example 5.4 dem<strong>on</strong>stratesrunning the FetchURL program.Example 5.4 Running a Java program with java$ java FetchURL http://www.yahoo.com/newshttp://www.yahoo.com/news:Yahoo! Directory News and Mediali { f<strong>on</strong>t-size: 12px; margin-bottom: 2px; }...... etc.CAUTIONRemember that if you override the classpath, either with the -classpath or-cp command-line opti<strong>on</strong>s (detailed below) or with the CLASSPATH envir<strong>on</strong>mentvariable, you must include the “.” directory somewhere in the classpathif you want Java to include current working directory in the search list. Since “.”is the default classpath, many people are surprised when they set a classpathand suddenly can no l<strong>on</strong>ger run a .class file in their current directory.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!