Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8206352

SWT Applications can not be started due to problem with -XstartOnFirstThread

XMLWordPrintable

    • x86
    • os_x

      A DESCRIPTION OF THE PROBLEM :
      If you try to start an swt-application via webstart you get the error

      This is my jnlp
      <?xml version="1.0" encoding="utf-8"?>
      <jnlp spec="1.0+" codebase="file:///Users/mkoch/Documents/VMs/eclipse_projects/Webstart">
          <information>
              
              <vendor>me</vendor>
          </information>
      <security>
      <all-permissions />
      </security>
          <resources>
           <!-- add -XstartOnFirstThread to the java-vm-args (don't forget APPLICATION_TEMPLATE.JNLP -->
           <j2se version="1.8+" java-vm-args="" />
           <nativelib href="lib/swt.jar" />
      <jar href="webstart.jar" main="true" />
      <jar href="lib/swt.jar" />
          </resources>
          <application-desc name="Webstart-Test" main-class="com.c4u.webstart.SWTTest">
           </application-desc>
      </jnlp>

      this is the exception (this is ok because swt says what is wrong)

      ***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread
      Juli 02, 2018 1:36:40 NACHM. com.c4u.webstart.SWTTest main
      SCHWERWIEGEND: error
      org.eclipse.swt.SWTException: Invalid thread access
      at org.eclipse.swt.SWT.error(SWT.java:4552)
      at org.eclipse.swt.SWT.error(SWT.java:4467)
      at org.eclipse.swt.SWT.error(SWT.java:4438)
      at org.eclipse.swt.widgets.Display.error(Display.java:1090)
      at org.eclipse.swt.widgets.Display.createDisplay(Display.java:842)
      at org.eclipse.swt.widgets.Display.create(Display.java:825)
      at org.eclipse.swt.graphics.Device.<init>(Device.java:129)
      at org.eclipse.swt.widgets.Display.<init>(Display.java:724)
      at org.eclipse.swt.widgets.Display.<init>(Display.java:715)
      at com.c4u.webstart.SWTTest.main(SWTTest.java:30)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.base/java.lang.reflect.Method.invoke(Unknown Source)
      at jdk.javaws@10.0.1/com.sun.javaws.Launcher.executeApplication(Unknown Source)
      at jdk.javaws@10.0.1/com.sun.javaws.Launcher.executeMainClass(Unknown Source)
      at jdk.javaws@10.0.1/com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
      at jdk.javaws@10.0.1/com.sun.javaws.Launcher.run(Unknown Source)
      at java.base/java.lang.Thread.run(Unknown Source)

      If I change
      <j2se version="1.8+" java-vm-args="" />
      to
      <j2se version="1.8+" java-vm-args="-XstartOnFirstThread" />
      I don't get an error but the application did not start.

      To ensure that this is not a swt issue I've created a second application that creates a simple awt-frame.
      Without -XstartOnFirstThread the awt-app starts as expected - with -XstartOnFirstThread I see the download progress and after that nothing happens (no app, no error).

      So in my opinion this is an issue while launching the application with activated -XstartOnFirstThead.
      /Users/mkoch/Library/Application Support/Oracle/Java/Deployment/log contains not really helpful informations.

      I have a small project with my testfiles that I can send you if you want.


            herrick Andy Herrick (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: