我已经从Eclipse 4.4 Luna导出了一个jar(不可执行),如图所示,并尝试使用JWrapper为Windows,OSX和Linux生成本机应用程序。我在终端中使用的命令是
My-MacBook-Pro-:JWrapper me$ java -Xmx512m -jar jwrapper-00031607960.jar SpaceInvaders/InvadersGame.jar
文件系统是这样的:
和xml文件jwrapper-spaceinvaders.xml
如下:
<!-- The name of the app bundle -->
<BundleName>SpaceInvaders</BundleName>
<!-- The specification for one app within the bundle -->
<App>
<Name>SpaceInvaders</Name>
<LogoPNG>SpaceInvaders/logo.png</LogoPNG>
<MainClass>InvadersGame</MainClass>
</App>
<SupportedLanguages>en</SupportedLanguages>
<!-- App is a per-user app, it won't elevate and install for all users and the shared config folder will be per-user -->
<InstallType>CurrentUser</InstallType>
<!-- Splash and Logo -->
<BundleLogoPNG>SpaceInvaders/logo.png</BundleLogoPNG>
<!-- JVM options (e.g. extra memory) -->
<JvmOptions>
<JvmOption>-Xmx256m</JvmOption>
</JvmOptions>
<!-- The JREs JWrapper should use for Windows, Linux32, Linux64... -->
<Windows32JRE>JRE-1.7/win32/jre1.7.0_05</Windows32JRE>
<Windows64JRE>JRE-1.7/win32/jre1.7.0_05</Windows64JRE>
<Linux32JRE>JRE-1.7/linux/jre1.7.0_13</Linux32JRE>
<Linux64JRE>JRE-1.7/linuxx64/jre1.7.0_13</Linux64JRE>
<Mac64JRE>JRE-1.7/macos64/jre1.7.0_45.jre</Mac64JRE>
<!-- The files that the app wants to bundle, here we have just one which is a JAR file and we specify that it should be on the launch classpath -->
<File classpath='yes'>SpaceInvaders/InvadersGame.jar</File>
但是当我尝试使用上面的命令从终端构建时出现以下错误:
JWrapper 00031607960
Resources not found (wrappers+lib), will extract jwrapper-00031607960.jar..
JWrapperCompiler started
JWrapper is performing a full build...
[Config] Building file is SpaceInvaders/InvadersGame.jar
[Updates] Checking for updates...
[Fatal Error] :1:1: Content is not allowed in prolog.
**********************************
* BUILD FAILED *
**********************************
** Reason: (see stacktrace below)
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:257)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:121)
at jwrapper.JWrapperCompiler.main(JWrapperCompiler.java:563)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at SecureRunner2.<init>(SecureRunner2.java:464)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at SecureRunner1.<init>(SecureRunner1.java:422)
at SecureRunner1.<init>(SecureRunner1.java:227)
at SecureRunner1.main(SecureRunner1.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at jwrapper.launch.JWCompiler.main(JWCompiler.java:112)
我想知道我的JAR文件是否可能没有被Eclipse正确构建,因为示例应用程序似乎构建正常,我只是根据给定的示例修改了xml文件。
答案 0 :(得分:0)
在终端输入的命令不正确,最后一部分应该给出.xml文件的路径,而不是.jar文件