Tutorial by Examples

Executable JAR files are the simplest way to assemble Java code into a single file that can be executed. *(Editorial Note: Creation of JAR files should be covered by a separate Topic.) * Assuming that you have an executable JAR file with pathname <jar-path>, you should be able to run it as f...
When an application has not been packaged as an executable JAR, you need to provide the name of an entry-point class on the java command line. Running the HelloWorld class The "HelloWorld" example is described in Creating a new Java program . It consists of a single class called HelloWo...
A Java entry-point class has a main method with the following signature and modifiers: public static void main(String[] args) Sidenote: because of how arrays work, it can also be (String args[]) When the java command starts the virtual machine, it loads the specified entry-point classes and...
This example covers common errors with using the 'java' command. "Command not found" If you get an error message like: java: command not found when trying to run the java command, this means that there is no java command on your shell's command search path. The cause could be: yo...
This is a continuation of the "main class" and "executable JAR" examples. Typical Java applications consist of an application-specific code, and various reusable library code that you have implemented or that has been implemented by third parties. The latter are commonly referr...
First of all, the problem of handling spaces in arguments is NOT actually a Java problem. Rather it is a problem that needs to be handled by the command shell that you are using when you run a Java program. As an example, let us suppose that we have the following simple program that prints the siz...
The java command supports a wide range of options: All options start with a single hyphen or minus-sign (-): the GNU/Linux convention of using -- for "long" options is not supported. Options must appear before the <classname> or the -jar <jarfile> argument to be recog...

Page 1 of 1