无法在 Vista Business 上执行 Java 应用程序 - “找不到主类...程序将退出”
我编写了一个需要 Java 1.6 的 Java GUI 应用程序(使用 Netbeans 6.7)。 我在 XP PC 和 Mac OSX (10.5.7) 上成功运行了它。
我的客户端运行的是 Vista Business,无法通过双击 jar 文件来运行该应用程序。 他可以从命令行执行它:“javaw -jar ...”收到的错误是:“找不到主类...程序将退出”。
我已要求客户端执行以下操作:
- 安装最新的 JRE
- 运行 JarFix
我已验证:
- JRE 安装在正确的位置
- jar 文件关联正确
- 应用程序可以工作(因为我已经在 XP 和 Mac OSX 上测试过它,并且客户端可以从命令行运行它)
任何关于我还可以调查什么的想法? 请注意,Netbeans 创建了主 jar 文件,以及一个包含其他几个 Jar 文件的 lib 目录。 我已经解压了 jar 文件并检查了清单文件(看起来不错)。 正确的主类也在应用程序的 jar 文件中。
客户端是否需要注意应用程序在 Vista 中的执行位置?
非常感谢。 普雷姆博
I have written a Java GUI app (using Netbeans 6.7) requiring Java 1.6. I successfully run it on my XP PC and also my Mac OSX (10.5.7).
My client is running Vista Business, and cannot run the application by double clicking the jar file. He can execute it from the command line: "javaw -jar ..." The error received is: "Cannot find the main class... Program will exit".
I've asked the client to do the following:
- install the latest JRE
- run JarFix
I've verified that:
- JRE is installed in correct location
- jar file association is correct
- application works (as I have tested it on XP and Mac OSX, and the client can run it from the command line)
Any ideas on what else I can investigate? Note, Netbeans created the main jar file, and also a lib directory with a couple of other Jarfiles. I've unzipped the jarfile and examined the manifest file (which looks good). The correct main class is also within the app's jarfile.
Does the client need to be careful as to where the application is executed from in Vista?
Thanks very much.
Prembo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
完全相同的 JAR 文件可以在其他操作系统上运行吗?
JAR 文件中的清单文件 (META-INF/MANIFEST.MF) 是否正确? 需要注意的一个问题是清单文件必须以空行结尾; 如果没有,清单文件中的最后一行将被忽略。 因此,例如,如果清单文件中的最后一行是这样的:
并且后面没有空行,那么 Java 将忽略该行,并且将无法找到程序的主类。
有关确切信息,请参阅 Sun 的有关在 JAR 文件中部署 Java 程序的 Java 教程有关如何将应用程序打包到 JAR 中的详细信息; 它还包含有关清单文件需要以空行结尾的警告。
另外,请仔细检查是否使用了正确的 Java 版本。 您使用的 Java 版本与 Windows XP 上的 Java 版本完全相同吗? 尝试:
查看正在使用哪个 Java 版本。
Does exactly the same JAR file work on other operating systems?
Is the manifest file (META-INF/MANIFEST.MF) in the JAR file correct? One catch to watch out for is that the manifest file MUST end with an empty line; if it doesn't, the last line in the manifest file will be ignored. So, for example, if the last line in your manifest file is something like this:
and it is not followed by an empty line, then Java will ignore the line and it will not be able to find the main class of the program.
See Sun's Java Tutorial about deploying Java programs in JAR files for exact details about how to package your application in a JAR; it also contains the warning about the manifest file needing to end with an empty line.
Also, double-check if the right version of Java is used. Are you using the exact same version of Java as on Windows XP? Try:
to see which Java version is being used.
我运行的是 Vista Enterprise,它与其他 Windows 版本(关于 Java)之间几乎没有什么区别。
以下是一些可能有效或无效的随机想法:
I'm running Vista Enterprise and have very little differences between it and other Windows versions (with regards to Java).
Here are some random ideas that may or may not work:
有时 JDK 需要与 net beans IDE 一起单独安装。 如果你安装了jdk,那么你可以尝试检查环境变量中的classpath、path。
Sometimes JDK needs to be installed separately,along with the net beans IDE. If you have jdk installed then you can try checking for classpath,path in the environmental variables.