简体   繁体   中英

Using java class path properly, clarification needed

I am running the program as:

java -Dfirstarg=$1 -cp $APP_HOME/someFile.cfg;$APP_HOME/lib/*.jar ::  Handler

With the intention to pass the argument and include someFile.cfg and all jars under $APP_HOME/lib/ to class path.

What am i doing wrong please?

You don't need to pass the someFile.cfg into the class-path. You just need to add the libraries, and current directory there.

I would do:

java -Dfirstarg=$1 -cp .:$APP_HOME/lib/*.jar YourMainClass

Assuming you are in a directory where your .class files are.

Also, do keep in mind that in linux you use : and not ; to separate your class path entries in the -cp arguments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM