Reputation: 683
Hy there,
i developed an application that is to be started via javaws, the application itself is tested to run on linux(ubuntu 10.04 LTS), windows 7 and mac OS. It's using swt and runs on all those platforms without problems if started locally.
after some struggling the application now starts on the linux and windows machines with all architectures quite well, if it wasn't for the mac!
I know that to run an swt application under macOS one needs to give the java-vm the XstartOnFirstThread
and to do same with javaws the jnlp file needs the following ressource tag:
<resources os="Mac">
<j2se version="1.5+" javaws-vm-args="-XstartOnFirstThread" />
<nativelib href="swt-3.6.2-cocoa-macosx-x86_64.jar" />
<jar href="swt-3.6.2-cocoa-macosx-x86_64.jar" />
</resources>
as discussed in this question macOS may have problems with swt and the j2se="xy"
definition so i tried it with a specific one, none at all (not even the global one) and the "generic" one (eg: j2se="1.5+"
).
i suspect that the argument javaws-vm-args="-XstartOnFirstThread"
or java-vm-args="-XstartOnFirstThread"
(found this argument with and without the "ws" part on the internet and tried both) is not passed on by javaws because the jar itself is running quite perfectly when executed locally on the mac.
The actual problem now is that with every possible combination of argumemts the application always exits with the following exception:
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.widgets.Display.error(Unknown Source)
at org.eclipse.swt.widgets.Display.createDisplay(Unknown Source)
at org.eclipse.swt.widgets.Display.create(Unknown Source)
at org.eclipse.swt.graphics.Device.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.<init>(Unknown Source)
at org.eclipse.swt.widgets.Display.getDefault(Unknown Source)
at foo.bar.WebStartRunnable.<init>(WebStartRunnable.java:85)
at foo.bar.WebStartRunnable.main(WebStartRunnable.java:155)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:1909)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1847)
at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1609)
at com.sun.javaws.Launcher.run(Launcher.java:138)
at java.lang.Thread.run(Thread.java:680)
Here are the specs again:
i hope someone had the same problem and was able to fix it, thx in advance for all answeres,
cheers stoppal
Upvotes: 0
Views: 1644
Reputation: 683
So for all out there that struggle with the same issue or just want a functioning jnlp file as reference, here's mine:
<?xml version="1.0" encoding="UTF-8" ?>
<jnlp spec="1.0+" codebase="http://your-host:8080/folder_with_jar_stuff/" href="webstart.jnlp">
<information>
<title>Your Applications Title</title>
<vendor>Your name or company or whatever</vendor>
<homepage href="http://www.a-really-funny-domain.com" />
<description>This application does something really usefull and will make the world a better place due to it being lorem ipsum...</description>
<icon kind="splash" href="splash.bmp"/>
</information>
<security>
<all-permissions />
</security>
<resources>
<jar href="your_app_as_jar.jar" />
</resources>
<resources os="Linux" arch="x86_64">
<nativelib href="swt-native-3.6.2-gtk-linux-x86_64.jar" />
</resources>
<resources os="Linux" arch="amd64">
<nativelib href="swt-native-3.6.2-gtk-linux-x86_64.jar" />
</resources>
<resources os="Linux">
<nativelib href="swt-native-3.6.2-gtk-linux-x86.jar" />
</resources>
<resources os="Mac" arch="x86_64">
<j2se version="1.6" java-vm-args="-XstartOnFirstThread" />
<nativelib href="swt-3.6.2-cocoa-macosx-x86_64.jar" />
</resources>
<resources os="Windows" arch="x86">
<nativelib href="swt-native-3.6.2-win32-x86.jar" />
</resources>
<resources os="Windows" arch="x86_64">
<nativelib href="swt-native-3.6.2-win32-x86_64.jar" />
</resources>
<resources os="Windows" arch="amd64">
<nativelib href="swt-native-3.6.2-win32-x86_64.jar" />
</resources>
<resources>
<jar href="log4j-1.2.16.jar" />
</resources>
<application-desc main-class="package.contains.class.with.main.method.ClassName" />
</jnlp>
i know that this is far from complete, but it works for me. Other usefull links were: A JNLP tag refference list and believe it or not, the specification from oracle.
Upvotes: 2
Reputation: 168845
The JNLP file is invalid. Check it with JaNeLA & correct any results in red before wondering why it might be failing on this, that or the other system.
Upvotes: 1