SWT application cannot be started with Oracle Java 7 on Mac [message #912347] |
Thu, 13 September 2012 07:52  |
Albert Pikus Messages: 70 Registered: October 2009 |
Member |
|
|
Hi,
my SWT application won't start from Eclipse on Mac (Mac OS X Lion) when using 64-bit Oracle Java 7 (build 1.7.0_05-b05), I get ***WARNING: Display must be created on main thread due to Cocoa restrictions.
It's a known requirement that -XstartOnFirstThread program argument must be passed when running SWT applications on Mac, which I have set inside Run > Debug Configurations > Arguments > Program Arguments for my debug configuration. It seems that Eclipse simply ignores this argument when running SWT app on Java 7, like it wasn't there. As soon as I switch to Java 6, everything is back to normal again. I'd be surprised if no one else encountered this problem.
The other problem that surfaced with Oracle Java 7 is starting (SWT) application bundled as a JAR. I have built a single JAR that also bundles other JAR libraries that my application uses, using the approach that worked perfectly for me for a long time, on all platforms (Windows, Mac and Linux), please see: http://stackoverflow.com/questions/2706222/create-cross-platform-java-swt-application
For starting my program on Mac, I use the following shell script:
#!/bin/sh
PROGRAM_DIR=`dirname "$0"`
PROGRAM_DIR=`cd "$PROGRAM_DIR"; pwd`
cd "${PROGRAM_DIR}"
for FILE in ./*.jar; do
CLASSPATH="${CLASSPATH:+${CLASSPATH}:}$FILE"
done
exec java \
-jar \
-Xms256m -Xmx512m \
-XstartOnFirstThread \
-cp "$\{CLASSPATH\}" \
application.jar
When I try to start my application on Mac with Oracle Java 7, this is the error that is printed in Terminal:
Error: Could not find or load main class application.jar
It seems that Java thinks that application.jar is a main CLASS that should be run. Again, this problem only appears with Java 7 and I don't have a slightest idea what is causing it.
I have no problems running my application with Java 7 on Windows, not from Eclipse and also not as a standalone JAR:
Has anyone encountered similar issues with Java 7 on Mac?
Thanks in advance, best regards,
Albert
[Updated on: Mon, 17 September 2012 10:31] Report message to a moderator
|
|
|