Java .jar 无法在 Windows 上运行

发布于 2024-11-26 11:17:49 字数 1639 浏览 0 评论 0原文

我正在 Fedora 15 下使用 Eclipse 进行开发。我导出了一个可运行的 jar。它在 Fedora 中运行良好。但我无法在windows上运行它。我已经安装了JRE。我什至尝试安装JDK。没有错误日志,应用程序只是没有启动。

这是输出

Microsoft Windows [Version 6.1.7601]
(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.

C:\Users\Артоюрос>java -jar C:\Lib.Ru2Epub.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:

        no swt-gtk-3735 in java.library.path
        no swt-gtk in java.library.path
        Can't load library: C:\Users\└ЁЄю■Ёюё\.swt\lib\win32\x86\swt-gtk-3735.dl
l
        Can't load library: C:\Users\└ЁЄю■Ёюё\.swt\lib\win32\x86\swt-gtk.dll

        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:285)
        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:194)
        at org.eclipse.swt.internal.C.<clinit>(C.java:21)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
        at org.eclipse.swt.widgets.Display.<clinit>(Display.java:132)
        at ru.lib.epub.MainWindow.main(MainWindow.java:28)
        ... 5 more

C:\Users\Артоюрос>

I am developing using Eclipse under Fedora 15. I exported a runnable jar. It works fine in Fedora. But I can't run it on windows. I have installed a JRE. I even tried installing JDK. There are no error logs, app just didn't start.

Here's the output

Microsoft Windows [Version 6.1.7601]
(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.

C:\Users\Артоюрос>java -jar C:\Lib.Ru2Epub.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:

        no swt-gtk-3735 in java.library.path
        no swt-gtk in java.library.path
        Can't load library: C:\Users\└ЁЄю■Ёюё\.swt\lib\win32\x86\swt-gtk-3735.dl
l
        Can't load library: C:\Users\└ЁЄю■Ёюё\.swt\lib\win32\x86\swt-gtk.dll

        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:285)
        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:194)
        at org.eclipse.swt.internal.C.<clinit>(C.java:21)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
        at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
        at org.eclipse.swt.widgets.Display.<clinit>(Display.java:132)
        at ru.lib.epub.MainWindow.main(MainWindow.java:28)
        ... 5 more

C:\Users\Артоюрос>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

美人骨 2024-12-03 11:17:49

正如 @a_horse_with_no_name 所说“打开命令提示符并运行 java -jar your.jar”。如果它有效,您必须将扩展名 *.jar 映射到名为“java”的程序。这就是 Windows 的工作原理。当双击 *.txt 文件启动记事本时,相同的机制也起作用。

由于我现在在 Linux 上,我无法告诉您如何将扩展名映射到程序,但它位于文件资源管理器菜单中的某个位置。

As @a_horse_with_no_name said "open command prompt and run java -jar your.jar". If it works you have to map extension *.jar to program named "java". This is how windows works. The same mechanism is working when double click on *.txt file starts Notepad.

Since I am on linux now I cannot tell you how to map the extension to program but it is somewhere in menus of file explorer.

挖个坑埋了你 2024-12-03 11:17:49

它应该是一个可运行的 jar ,因此您可以通过双击在 Windows 上运行它。

it should be a runnable jar , so you can run it on windows using double click.

月光色 2024-12-03 11:17:49

你可能正在使用绝对路径引用资源..因为你说你是在 Linux 上开发的应用程序。你可能会说 new File("/etc/fstab");.. 这在 Windows 上会失败,因为它没有这样的文件系统。

通常情况就是这样。

you may be referencing a resource using absolute path.. since you say you developed the app on Linux. you might have said new File("/etc/fstab");.. this would fail on windows as it does not have a file system like this.

this would usually be the case.

野稚 2024-12-03 11:17:49

swt dll 有问题。

  1. 检查文件 C:\Users\└ЁЄю■Ёюё.swt\lib\win32\x86\swt-gtk.dll 是否存在,
  2. 也许您无法加载它,因为您没有管理员权限?然后
    转到Eclipse安装路径,右键单击eclipse.exe并选择“Properites”。从 eclipse.exe 属性弹出窗口中选择“兼容性”选项卡,然后在选项卡底部选中“权限级别”类别中的以下复选框“以管理员身份运行此程序”。这应该可以解决问题。
  3. 有时只需将 dll 添加到 lib 文件夹中就会有所帮助

There is a problem with swt dlls.

  1. check if the file C:\Users\└ЁЄю■Ёюё.swt\lib\win32\x86\swt-gtk.dll exists
  2. maybe you can't load it coz u don't have admin privileges? Then
    Goto Eclipse installation path, right click on eclipse.exe and select "Properites". From the eclipse.exe Properties pop-up select "Compatibility" tab and at the bottom of the tab check the following check box "Run this program as administrator" in "Previlege Level" category. This should solve the problem.
  3. Sometimes simply adding dlls into lib folder helps
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文