Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JAVA SWT/AWT Eclipse Mac OSX Java Cocoa CompatibilityMode Enabled

I'm developing a fairly complex Java application mixing Swing and SWT. Whenever I start the application, this is the console output (and the app doesn't show up):

2012-12-19 12:45:45.359 java[3442:f07] [Java CocoaComponent compatibility mode]: Enabled
2012-12-19 12:45:45.360 java[3442:f07] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000

I've followed many guides and tutorials setting:

  1. System.setProperty("com.apple.awt.CocoaComponent.CompatibilityMode", "false");
  2. -XstartOnSecondThread
  3. --launcher-on-secondThread

Now I really don't have any clue. The only way to make my app working on Mac OSX is to export the Eclipse project to a JAR executable. Well, this is annoying. Can someone explain to me how to set those properties above? Are there any magic trick?

EDIT: I'm using:

OSX Mountain Lion 10.8.2 ,
Java 1.6u37 64bit,
SWT 4.2 cocoa x64,
Windows XP ,
Java 1.6u37 32bit,
SWT 4.2 32bit 
like image 374
neo Avatar asked Dec 19 '12 11:12

neo


Video Answer


1 Answers

I've had this issue several times, as I work in a Java shop where everyone uses Eclipse, and I'm an OS X user.

The fix is a little weird.

You need to remove your current JRE from the "Installed JREs" preference, and then add it again. When you do so, make sure that you select "Standard JVM" and not "Mac OS X JVM".

Adding JREs is a little annoying, so take note of the "Location" path string before you do so. You'll point it to the same place, just change the "Type" property.

So, my answer is wrong. It's pertinent if you're doing Swing/AWT only, but humorously enough immediately after posting this I had to write an SWT_AWT boondoggle and I got the same error on my Mac, even with the above settings. I suspect that it has to do with the differences between Swing/AWT and SWT regarding the event loop (SWT = bring your own, Swing = provided by JVM). I also get the error in IntelliJ IDEA 12, so it can't just be an Eclipse issue.

like image 96
Doug Stephen Avatar answered Sep 20 '22 01:09

Doug Stephen