-1

I'm trying to run a regular .jar not runable .jar file using a .bat file

The jar file is named mytest.jar, and I'm trying to execute it using in the .bat file:

java -classpath "mytest.jar" 

and it doesn't work.

Gal Sosin
  • 714
  • 7
  • 27

1 Answers1

2

If it is an executable jar

You need to put the -jar flag.

Use:

java -jar /path/to/your/jar/mytest.jar

If it is a regular jar file

you need to use:

java -cp $CLASSPATH:/path/to/your/jar/mytest.jar YourMainClass

and on Windows,

java -cp %CLASSPATH%;/path/to/your/jar/mytest.jar YourMainClass
Aditya Singh
  • 2,343
  • 1
  • 23
  • 42