简体   繁体   English

设置类路径Java错误

[英]Setting the classpath java error

I am trying to follow this tutorial to be able to use Jade (Java Agent Development Framework). 我正在尝试按照教程使用Jade(Java代理开发框架)。 I am pretty new with java. 我对Java很陌生。 I have a problem with this command: (I am using Mac OSx) 我对此命令有疑问:(我使用的是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" ... . 尝试在类路径周围添加引号: 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 如果没有它们,bash会将分号解释为新命令的开始,这将导致错误消息-bash: classes: command not found

Edit 编辑

It just struck me that you of course are running in *nix. 令我惊讶的是,您当然是在* nix中运行的。 Then the path separator would be : , not ; 那么路径分隔符将是: ,而不是; . Then the quotes shouldn't even be needed. 然后甚至不需要引号。 Semi colon is the path separator in Windows. 半冒号是Windows中的路径分隔符。

Try 尝试

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

Looks like bash is treating the ; 好像bash正在治疗; as end of command and treats classes as a new command. 作为命令的结尾,并将类视为新命令。

The command is in Windows notation, not Unix one. 该命令使用Windows表示法,而不是Unix。 On Unix systems You have to use lib/jade.jar instead of lib\\jade.jar 在Unix系统上,必须使用lib / jade.jar而不是lib \\ jade.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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