简体   繁体   English

JAVA SWT / AWT Eclipse Mac OSX Java Cocoa CompatibilityMode已启用

[英]JAVA SWT/AWT Eclipse Mac OSX Java Cocoa CompatibilityMode Enabled

I'm developing a fairly complex Java application mixing Swing and SWT . 我正在开发一个混合SwingSWT的相当复杂的Java应用程序。 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 . 使我的应用程序在Mac OSX上运行的唯一方法是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 

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. 我曾经多次遇到这个问题,因为我在一个Java商店工作,每个人都使用Eclipse,而我是OS X用户。

The fix is a little weird. 修复有点奇怪。

You need to remove your current JRE from the "Installed JREs" preference, and then add it again. 您需要从“已安装的JRE”首选项中删除当前的JRE,然后再次添加它。 When you do so, make sure that you select "Standard JVM" and not "Mac OS X JVM". 执行此操作时,请确保选择“标准JVM”而 不是 “Mac OS X JVM”。

Adding JREs is a little annoying, so take note of the "Location" path string before you do so. 添加JRE有点烦人,因此在执行此操作之前请记下“位置”路径字符串。 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. 如果你只是在做Swing / AWT,这是相关的,但是在发布之后我立即幽默地写了一个SWT_AWT boondoggle并且我在我的Mac上得到了同样的错误,即使使用上述设置也是如此。 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). 我怀疑它与Swing / AWT和SWT之间关于事件循环的差异有关(SWT =自带,Swing =由JVM提供)。 I also get the error in IntelliJ IDEA 12, so it can't just be an Eclipse issue. 我也在IntelliJ IDEA 12中得到错误,所以它不仅仅是一个Eclipse问题。

I had the same problem in my Macbook, as I can see you're downloading the Eclipse Indigo, which is the best you can do. 我在Macbook中遇到了同样的问题,因为我可以看到你正在下载Eclipse Indigo,这是你能做的最好的。 Juno has bugs and also is slow since it consumes more performance than previous releases. Juno有bug,也很慢,因为它比以前的版本消耗更多的性能。 I think Indigo is the best option. 我认为Indigo是最好的选择。 I know Java is portable and multi-platform but after being working with apple devices I found some kind of incompatibilities with Java, I think not because of Java, but because of the iOS, that's why for me the best I could do was to install a virtual machine with Ubuntu. 我知道Java是可移植和多平台的,但是在使用苹果设备之后我发现了一些与Java的不兼容性,我认为不是因为Java,而是因为iOS,这就是为什么对我来说我能做的最好就是安装一个使用Ubuntu的虚拟机。 So you can try the same with the Linux distribution you prefer. 因此,您可以尝试使用您喜欢的Linux发行版。

i had a simular problem when i used a jar for generating graphs. 当我使用jar来生成图表时,我遇到了类似的问题。 je jar used swt which seem to be not compatible with OSX. je jar使用的swt似乎与OSX不兼容。 If you have are using swt or have imported a jar using swt try deleting it and fiding an equivalent that uses awt 如果您正在使用swt或使用swt导入了jar,请尝试删除它并使用awt来修复等效项

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

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