Java .jar 无法在 Windows 上运行
我正在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如 @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.
它应该是一个可运行的 jar ,因此您可以通过双击在 Windows 上运行它。
it should be a runnable jar , so you can run it on windows using double click.
你可能正在使用绝对路径引用资源..因为你说你是在 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.
swt dll 有问题。
转到Eclipse安装路径,右键单击eclipse.exe并选择“Properites”。从 eclipse.exe 属性弹出窗口中选择“兼容性”选项卡,然后在选项卡底部选中“权限级别”类别中的以下复选框“以管理员身份运行此程序”。这应该可以解决问题。
There is a problem with swt dlls.
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.