David Faizulaev
David Faizulaev

Reputation: 5721

Running jar file from cmd with reference to external jars

I would like to know can I run a jar file from the command, with the jar file using log4j and ojdbc.jar as well.

The 'main' is located in: nmap_logic.jar. Within the package containing the 'main' is called: "nn.gmap.logic".

I also use 2 external jar files: log4j.jar & ojdbc.jar.

I have tried running:

java -cp "nmap_logic.jar;log4j.jar;ojdbc.jar" nn.gmap.logic.NNmain

And I get an error that the log4j cannot be initialized.

From the Eclipse environment the application runs fine.

Please let me know how should I execute the command properly.

Thanks.

Upvotes: 1

Views: 934

Answers (1)

Tarlog
Tarlog

Reputation: 10154

Try to give the full path to the jars. I believe that there is a difference between what you think is your root folder and what Java thinks about it.

Something like java -cp "c:\myjars\nmap_logic.jar;c:\myjars\log4j.jar;c:\myjars\ojdbc.jar" nn.gmap.logic.NNmain

Btw, you can also do the following: java -cp "c:\myjars\*" nn.gmap.logic.NNmain

Upvotes: 2

Related Questions