Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Before reading these instructions, you will want to follow read Installing HPS Java in order  which explains how to build or obtain get an HPS Java distribution jar file.

...

Distribution Jar

Any references to hps-distribution-bin.jar in command syntax should actually be replaced by the path to the HPS Java distribution jar.  The distribution jar file contains all of the project's dependencies in a distribution that can be run standalone using the java command.  The distribution will have "-bin" in the name.

This jar file should be found in your copy of HPS Java once you have built it locally using Maven.

Code Block
languagebash
cd hps-java-trunk; ls distribution/target/hps-distribution-3.6-SNAPSHOT-bin.jar

In the commands below, the version, here "3.6-SNAPSHOT", is generally left out for brevity.  When The version in subsequent commands will be left out for brevity, and because it will change depending on the version of the distribution you are using.  Of course, when executing commands you need to point to use the path of an actual distribution jar that you have built or downloaded.The jar file contains all of the project's dependencies in a distribution that can be run standalone using the java commandjar!

Any references to hps-distribution-bin.jar in command line syntax used on this page should actually be replaced by the path to the HPS Java distribution jar.

Running the Jar File

Java The distribution jar files can be run in two basic ways.  You can run a default main method using the -jar switch, or you can activate any class's main method and use -cp to supply a list of jar files jars in the classpath using the -cp switchand activate any class's main method.

Running the Default Main

Using the -jar switch from the command line will run the main from the class JobManager, which is listed is specified inside a special manifest file in the manifest inside the jardistribution jar (in case you were wondering how that works).

Code Block
languagebash
java -jar ./distribution/target/hps-distribution-bin.jar [args]

Without any arguments, it will print the command line options and then exit.

...

To be directly accessible from the command line, a class must have the following features.

  • It must be marked as public or it will not be accessibleas public.
  • It must have a public static method called  method called main (as shown above).
  • The main method has must have an array of strings as input (with the command line arguments)an input variable.

Assuming that MyClass Assuming the above class was bundled inside the distribution (which it isn't because it is just a dummy example!), it could be run from the command line via its main method as follows.

Code Block
languagebash
java -cp ./distribution/target/hps-distribution-bin.jar org.example.MyClass arg1 arg2 [...]

Most classes that implement a command line interface will print out help when run with no options e.g.

Code Block
languagebash
java -cp ./distribution/target/hps-distribution-bin.jar org.hps.evio.Evio2Lcio

If implemented by the author, then -h is also usually used equivalently to print out a help menu.

...