【问题标题】:Swing/SWT Java error related to menu conflict与菜单冲突相关的 Swing/SWT Java 错误
【发布时间】:2014-06-20 11:29:59
【问题描述】:

我的开发人员为我更新了一个 java 应用程序,但在发送更新时忽略了包含 build.xml。现在,当我在 Eclipse (OSX) 中作为应用程序进行调试时,会弹出应用程序界面,但不可点击,并将以下内容返回到控制台

2014-05-03 19:12:53.513 java[37325:d07] [Java CocoaComponent compatibility mode]: Enabled
2014-05-03 19:12:53.514 java[37325:d07] [Java CocoaComponent compatibility mode]: Setting timeout for SWT to 0.100000
***WARNING: Display must be created on main thread due to Cocoa restrictions.
2014-05-03 19:12:55.126 java[37325:d07] _createMenuRef called with existing principal MenuRef already associated with menu
2014-05-03 19:12:55.126 java[37325:d07] (
    0   CoreFoundation                      0x00007fff9025625c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8d95ce75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff9025610c +[NSException raise:format:] + 204
    3   AppKit                              0x00007fff91a8fe84 -[NSCarbonMenuImpl _createMenuRef] + 62
    4   AppKit                              0x00007fff91a8f85a -[NSCarbonMenuImpl _instantiateCarbonMenu] + 143
    5   AppKit                              0x00007fff91a8e022 -[NSApplication finishLaunching] + 876
    6   libswt-pi-cocoa-3740.jnilib         0x0000000113540b3d Java_org_eclipse_swt_internal_cocoa_OS_objc_1msgSendSuper__Lorg_eclipse_swt_internal_cocoa_objc_1super_2J + 89
    7   ???                                 0x0000000109164cd5 0x0 + 4447423701
)
Loading
Ready

当我上次与我的开发人员交谈时,他说他会在几天后重新发送,但同时他说我可以使用以前版本的 build.xml 并删除 djswing 和 SWT来自 build.xml 文件,他说这导致了以前版本中的错误。

问题是除了引用这些的两行之外没有什么特别的。这是来自 build.xml 的代码

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. -->
<project basedir="." default="build" name="okc">
    <property environment="env"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.5"/>
    <property name="source" value="1.5"/>
    <path id="okc.classpath">
        <pathelement location="bin"/>
        <pathelement location="lib/AbsoluteLayout.jar"/>
        <pathelement location="lib/appframework-1.0.3.jar"/>
        <pathelement location="lib/beansbinding-1.2.1.jar"/>
        <pathelement location="lib/commons-codec-1.4.jar"/>
        <pathelement location="lib/commons-httpclient-3.1.jar"/>
        <pathelement location="lib/commons-logging-1.1.1.jar"/>
        <pathelement location="lib/javax-jmi-reflect.jar"/>
        <pathelement location="lib/swing-layout-1.0.4.jar"/>
        <pathelement location="lib/swing-worker-1.1.jar"/>
        <pathelement location="lib/toplink-essentials-agent.jar"/>
        <pathelement location="lib/toplink-essentials.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src" excludes="**/*.launch, **/*.java"/>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
            <src path="src"/>
             <classpath refid="okc.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="OkcApp">
        <java classname="okc.OkcApp" failonerror="true" fork="yes">
            <classpath refid="okc.classpath"/>
        </java>
    </target>
</project>

任何帮助将不胜感激。提前致谢。

【问题讨论】:

    标签: java eclipse macos swing swt


    【解决方案1】:

    在运行程序时指定-XstartOnFirstThread 选项。这应该会在正确的线程上创建显示。

    【讨论】:

    • 不,这会导致“无效线程访问”异常。我也有“_createMenuRef”错误,即使我正在使用-XstartOnFirstThread
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-05
    • 2018-04-05
    • 2011-01-19
    • 2015-11-17
    • 2011-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多