简体   繁体   English

Java .jar未在Windows上运行

[英]Java .jar not running on windows

I am developing using Eclipse under Fedora 15. I exported a runnable jar . 我正在Fedora 15下使用Eclipse进行开发。我导出了一个可运行的jar It works fine in Fedora. 它在Fedora中工作正常。 But I can't run it on windows. 但是我不能在Windows上运行它。 I have installed a JRE. 我已经安装了JRE。 I even tried installing JDK. 我什至尝试安装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\Артоюрос>

As @a_horse_with_no_name said "open command prompt and run java -jar your.jar". 就像@a_horse_with_no_name所说的“打开命令提示符并运行java -jar your.jar”。 If it works you have to map extension *.jar to program named "java". 如果可行,则必须将扩展名* .jar映射到名为“ java”的程序。 This is how windows works. Windows就是这样工作的。 The same mechanism is working when double click on *.txt file starts Notepad. 双击* .txt文件启动记事本时,相同的机制也起作用。

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. 由于我现在使用的是Linux,因此我无法告诉您如何将扩展名映射到程序,但是它位于文件浏览器菜单中的某处。

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

you may be referencing a resource using absolute path.. since you say you developed the app on Linux. 因为您说您是在Linux上开发应用程序,所以您可能使用绝对路径引用资源。 you might have said new File("/etc/fstab"); 您可能已经说过new File("/etc/fstab"); .. this would fail on windows as it does not have a file system like this. ..这将在Windows上失败,因为它没有这样的文件系统。

this would usually be the case. 通常是这种情况。

There is a problem with swt dlls. swt dll有问题。

  1. check if the file C:\\Users\\└ЁЄю■Ёюё.swt\\lib\\win32\\x86\\swt-gtk.dll exists 检查文件C:\\ Users \\└ЁЄю■Ёюё.swt\\ lib \\ win32 \\ x86 \\ swt-gtk.dll是否存在
  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". 然后转到Eclipse的安装路径,右键单击eclipse.exe并选择“属性”。 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. 从eclipse.exe属性弹出窗口中,选择“兼容性”选项卡,然后在该选项卡底部的“特权级别”类别中选中以下复选框“以管理员身份运行该程序”。 This should solve the problem. 这应该可以解决问题。
  3. Sometimes simply adding dlls into lib folder helps 有时只需将dll添加到lib文件夹中即可

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

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