无法在 Vista Business 上执行 Java 应用程序 - “找不到主类...程序将退出”

发布于 2024-08-02 00:30:17 字数 722 浏览 2 评论 0原文

我编写了一个需要 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甚是思念 2024-08-09 00:30:17

完全相同的 JAR 文件可以在其他操作系统上运行吗?

JAR 文件中的清单文件 (META-INF/MANIFEST.MF) 是否正确? 需要注意的一个问题是清单文件必须以空行结尾; 如果没有,清单文件中的最后一行将被忽略。 因此,例如,如果清单文件中的最后一行是这样的:

Main-Class: com.mypackage.MyProgram

并且后面没有空行,那么 Java 将忽略该行,并且将无法找到程序的主类。

有关确切信息,请参阅 Sun 的有关在 JAR 文件中部署 Java 程序的 Java 教程有关如何将应用程序打包到 JAR 中的详细信息; 它还包含有关清单文件需要以空行结尾的警告。

另外,请仔细检查是否使用了正确的 Java 版本。 您使用的 Java 版本与 Windows XP 上的 Java 版本完全相同吗? 尝试:

java -version

查看正在使用哪个 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:

Main-Class: com.mypackage.MyProgram

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:

java -version

to see which Java version is being used.

岁月流歌 2024-08-09 00:30:17

我运行的是 Vista Enterprise,它与其他 Windows 版本(关于 Java)之间几乎没有什么区别。

以下是一些可能有效或无效的随机想法:

  • 您尝试过吗:右键单击 Jar -> 。 打开-> Java(TM) Platform SE Binary
  • 是否与权限相关? (可能不是,因为它是通过命令行运行的)
  • 您是否在关闭 UAC 的情况下尝试过它? (UAC 沙箱 java 应用程序,它们无法写入某些位置,例如程序文件)
  • 您是否确保它们在 JAVA_HOME/lib/ext/ 中具有与您相同的文件,
  • 您可以尝试设置环境变量:
    • JAVA_HOME=
    • CLASSPATH=。
    • PATH=\bin

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:

  • Have you tried: right clicking on the Jar -> Open with -> Java(TM) Platform SE Binary
  • Could it be permissions related? (probably not since it runs via the command line)
  • Have you tried it with UAC off? (UAC sandboxes java apps, and they can't write to certain locations like Program Files)
  • Did you make sure they have the same files as you in JAVA_HOME/lib/ext/
  • you could try setting environment variables:
    • JAVA_HOME=<your_java_home>
    • CLASSPATH=.
    • PATH=<your_java_home>\bin
梨涡少年 2024-08-09 00:30:17

有时 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文