简体   繁体   English

Linux上的Java -cp

[英]Java -cp on linux

I made a program which runs fine on windows. 我做了一个可以在Windows上正常运行的程序。 When I moved it over to CentOS, I got this error: 当我将其移至CentOS时,出现以下错误:

Error: Could not find or load main class org.wbc.WBCController 错误:找不到或加载主类org.wbc.WBCController

This is the file setup and .sh on linux: 这是Linux上的文件设置和.sh: linux

And this is the file setup and .bat on windows: 这是Windows上的文件设置和.bat:

视窗

Does anybody know what the problem is, and how I can fix it? 有人知道问题是什么,如何解决?

Java will respond with this error even if it cannot find the file wbc.jar. 即使找不到文件wbc.jar,Java也会响应此错误。 I am guessing that that is your problem. 我猜那是你的问题。 You might want to see that your are executing the shell script from within the right working directory. 您可能希望看到您正在从正确的工作目录中执行Shell脚本。

Check to see if you can run wbc.sh from the console or put this in wbc.sh to make sure it searches for the jar in the same directory as the shell script: 检查是否可以从控制台运行wbc.sh或将其放在wbc.sh中,以确保它在与Shell脚本相同的目录中搜索jar:

#!/bin/sh
java -cp `dirname $0`/wbc.jar org.wbc.WBCController

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

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