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
How To Run A JAR File In Linux. If you have Java installed on your Linux, you will be able to run the JAR file with a double-click or picking option from right-click. You only need Java Runtime Environment and you will be able to easily run the file in Linux.
Description. The jar command is a general-purpose archiving and compression tool, based on ZIP and the ZLIB compression format. However, the jar command was designed mainly to package Java applets or applications into a single archive.
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. The argument 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With