How to set the classpath to the current directory and also run the jar file named
load.jar present in the current directory by providing the argument as
load=2 from a linux command line.
I did try to run the jar as follows but its executing classes from some other directory.
java -cp ./load.jar:$CLASSPATH load.Start load=2
This question is tagged with
~ Asked on 2013-11-11 11:07:43
Running a from class inside your JAR file
load.jar is possible via
java -jar load.jar
When doing so, you have to define the application entry point. Usually this is done by providing a manifest file that contains the
Main-Class tag. For documentation and examples have a look at this page.
load=2 can be supplied like in a normal Java applications:
java -jar load.jar load=2
Having also the current directory contained in the classpath, required to also make use of the
Class-Path tag. See here for more information.
~ Answered on 2013-11-11 11:11:33
For example to execute from terminal (Ubuntu Linux) or even (Windows console) a java file called filex.jar use this command:
java -jar filex.jar
The file will execute in terminal.
~ Answered on 2014-12-05 14:21:26