Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Linux by (18.4k points)

How to set a classpath to my current directory and also run my jar file named load.jar present in a current directory by providing this argument as load=2 from this Linux command line.

I did try to run the jar as follows but it's executing classes from some other directory.

java -cp ./load.jar:$CLASSPATH load.Start load=2

1 Answer

0 votes
by (36.8k points)
edited by

Running the from class inside the JAR file load.jar is possible via

java -jar load.jar

When you are doing, you need to define your application entry point. Usually this is done by providing the manifest file that contains a Main-Class tag.  The argument load is 2 can be supplied like in a normal Java applications:

java -jar load.jar load=2

Having also my current directory contained in my class path, required to also make use of my Class-Path tag. 

Want to be a Linux expert? Come and join this linux course

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Nov 30, 2020 in Linux by dev_sk2311 (45k points)

Browse Categories

...