简体   繁体   中英

Setting the classpath java error

I am trying to follow this tutorial to be able to use Jade (Java Agent Development Framework). I am pretty new with java. I have a problem with this command: (I am using Mac OSx)

java -cp lib\jade.jar;classes jade.Boot -gui -agents ping1:examples.PingAgent.PingAgent 

I get this error:

Usage: java [-options] class [args...]
       (to execute a class)
or  java [-options] -jar jarfile [args...]
       (to execute a jar file)
...
-bash: classes: command not found

I have set my environment variables like this:

export CLASSPATH=$CLASSPATH:/Applications/jade/classes
export CLASSPATH=$CLASSPATH:/Applications/jade/lib/jade.jar

and here is the hierarchy of the folders: 在此处输入图片说明

If you need some more information to understand the problem please let me know.

Try adding quotes around your class path: java -cp "lib\\jade.jar;classes" ... . Without them, bash interprets the semi colon as the start of a new command, which causes the error message -bash: classes: command not found

Edit

It just struck me that you of course are running in *nix. Then the path separator would be : , not ; . Then the quotes shouldn't even be needed. Semi colon is the path separator in Windows.

Try

java -cp "lib\jade.jar;classes" jade.Boot -gui -agents ping1:examples.PingAgent.PingAgent 

Looks like bash is treating the ; as end of command and treats classes as a new command.

The command is in Windows notation, not Unix one. On Unix systems You have to use lib/jade.jar instead of lib\\jade.jar

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