Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR(Using Oxygen had no trouble exporting as JAR files, but Photon will not do the simplest Windomaker app.)
Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1797282] Mon, 29 October 2018 13:51 Go to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 84
Registered: March 2018
Member
I'd been working on a fairly complex program on my old Mac and Oxygen. No problems. Switched to new Mac running High Sierra, and couldn't make a JAR from the same code. Couldn't see any error messages and couldn't find anything suspicious on the Console output. Stimied, I made a new workplace and made a WindowMaker app with only a button. Tried to make a JAR with that dead-simple code, which still gives me:
The Java JAR file "Ragger.jar" could not. be launched. Check the Console for possible error messages."

I have copied out a run of console outputs. Relevant material may begin on line 33.
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1797658 is a reply to message #1797282] Sun, 04 November 2018 07:02 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3296
Registered: July 2009
Senior Member

What are the steps for someone to reproduce the problem? Making a JAR is usually just an Export operation.

Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798029 is a reply to message #1797658] Sun, 11 November 2018 05:45 Go to previous messageGo to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 84
Registered: March 2018
Member
I just tried making a runnable JAR on my older Mac, and the results were the same. I made a basic "hello world" java project. When I exported it,I got a warning message saying the JAR could not be launched.

I checked for the JRE and it was an early one, so I tried installing jre-u-macos-x64.
"The Java JAR file "test.jar" could not be launched. Check the console for possible error messages. "

I looked for error messages in the console, but there was nothing there.

I had begun to doubt that I was not doing whatever I had done before that worked, so I used a Youtube tutorial. But it did it basically my way, and the results were still the same.

Is there a problem with my JRE?

Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798030 is a reply to message #1798029] Sun, 11 November 2018 06:00 Go to previous messageGo to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 84
Registered: March 2018
Member
I see that there are three different jdk files in my JavaVirtualMachines folder:
jdk-1.8.0_171.jdk
jdk-9.0.4.jdk
jdk-1.8.0.51.jdk
But those are all different from the dmg that has jre-8u191-macosx-x64.dmg
and I just opened that and ran the installer. I can't find anything other than the above three jdk files, however.
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798033 is a reply to message #1798030] Sun, 11 November 2018 09:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29649
Registered: July 2009
Senior Member
On the Mac you can use "/usr/libexec/java_home -X" to see which Java versions you have installed (and that the system knows about). As of Java 9, modules start to kick in, and that may affect your ability to launch with a jar. I'm not sure. Check in Window -> Preferences -> Java -> Installed JREs, which JRE are you actually using?

Also, when you launch something, the Debug perspective's Debug view should show information about what was launched. The properties will show you the command line that you could try run directly in a Terminal window to see if you can figure out how one should correctly launch your jar...
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798036 is a reply to message #1798033] Sun, 11 November 2018 13:49 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 423
Registered: August 2014
Senior Member
I created a dead-simple SWT application which just creates a MainWindow, Display and Shell. It was running fine from Eclipse, but refused to start from JAR:

tauno-voipios-macbook-pro-2:Desktop tauno$ java -jar SWT.jar
***WARNING: Display must be created on main thread due to Cocoa restrictions. Use vmarg -XstartOnFirstThread
org.eclipse.swt.SWTException: Invalid thread access
at org.eclipse.swt.SWT.error(SWT.java:4595)
at org.eclipse.swt.SWT.error(SWT.java:4510)
at org.eclipse.swt.SWT.error(SWT.java:4481)
at org.eclipse.swt.widgets.Display.error(Display.java:1091)
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:843)
at org.eclipse.swt.widgets.Display.create(Display.java:826)
at org.eclipse.swt.graphics.Device.<init>(Device.java:132)
at org.eclipse.swt.widgets.Display.<init>(Display.java:725)
at org.eclipse.swt.widgets.Display.<init>(Display.java:716)
at org.eclipse.swt.widgets.Display.getDefault(Display.java:1425)
at com.jcg.rca.main.MainWindow.open(MainWindow.java:27)
at com.jcg.rca.main.MainWindow.main(MainWindow.java:17)


tauno-voipios-macbook-pro-2:Desktop tauno$ java -XstartOnFirstThread -jar SWT.jar
tauno-voipios-macbook-pro-2:Desktop tauno$

As seen above, it did run fine with the added -XstartOnFirstThread.

A question: Is there a way to pack the JAR so that the extra argument will not be needed?


--

Tauno Voipio
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798040 is a reply to message #1798036] Sun, 11 November 2018 16:25 Go to previous messageGo to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 84
Registered: March 2018
Member
Thank you very much. I know nothing about the -xStart business. I want to send my JARs out to other teachers and students of Chinese, and I can't expect them to start this program every time from the console. I can't understand why the ordinary "export as runnable JAR" method used to work fine but now messes up.

I think that is what you are asking in your question.
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798043 is a reply to message #1798040] Sun, 11 November 2018 19:14 Go to previous messageGo to next message
Tauno Voipio is currently offline Tauno VoipioFriend
Messages: 423
Registered: August 2014
Senior Member
Exactly.


--

Tauno Voipio
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798044 is a reply to message #1798033] Sun, 11 November 2018 20:17 Go to previous messageGo to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 84
Registered: March 2018
Member
Thanks.

I don't know what Window -> Preferences -> Java -> Installed JRE means. I can't find a drop-down menu in Eclipse like that. I don't know what "Window" refers to.

From the Console, following your instructions, I get:
com.oracle.java.9.0.4.jdk
com.oracle.java.8u171.jdk
/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk
Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk
Library/Java/JavaVirtualMachines/1.6.0.jdk
com.oracle.java.8u51.jdk
com.apple.javajdk16

From the debug perspective I get:
/Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/Contents/Home/bin/java

I checked the System Preferences button on Java, which led to the Java Contol Panel. There it says the "your system has the recommended version 8 update 191. I did download and install jre-Bu191-macosx=-x64.dmg

I tried making a runnable exe file, and when I tried to launch it from the desktop I got an error that said running it required a legacy version of Java.
I think I forgot to write down what it said, but my history shows I got it
from: Download Java for OS X 2017-001
support.apple.com

I installed that but I still cannot run any exe file. Now the name of my exe file just flickers on in the bottom gutter and disappears.

I just tried running a JAR from the console, and that worked. Here is what I got back from the console:
\Patricks-MacBook-Pro-4:Desktop patrickedwinmoran$ java -jar Insight2.jar
java.lang.IllegalStateException: SQLite JDBC: inconsistent internal state
at org.sqlite.core.CoreResultSet.checkCol(CoreResultSet.java:81)
at org.sqlite.jdbc3.JDBC3ResultSet.getColumnCount(JDBC3ResultSet.java:699)
at net.proteanit.sql.DbUtils.resultSetToTableModel(DbUtils.java:17)
at Insight.fillComboBox(Insight.java:120)
at Insight.<init>(Insight.java:259)
at Insight$1.run(Insight.java:49)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
at java.desktop/java.awt.EventQueue.access$500(EventQueue.java:97)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:717)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:711)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:89)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:199)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Patricks-MacBook-Pro-4:Desktop patrickedwinmoran$

Having seen that the executable jar will work o.k. that way, I double-clicked on insight.jar and got the message:
The Java JAR file "Insight2.jar" could not be launched.

I've opened up the JAR, but I can't see anything that makes it runnable from the desktop. Somewhere in the JAR file there should be a clue to the operating system of which version of Java applies to this particular JAR file.
I see that there is a java control panel that can be reached via system preferences.

Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798054 is a reply to message #1798044] Mon, 12 November 2018 03:41 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 3296
Registered: July 2009
Senior Member

"Window -> Preferences -> Java -> Installed JRE" means to start from the menu named "Window" in your
menu bar. You can also use Ctrl/Cmd+3 and start typing "Installed JREs" to get to the right preference
page (or as I test it, one under that one).


Nitin Dahyabhai
Eclipse Web Tools Platform
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798068 is a reply to message #1798054] Mon, 12 November 2018 08:03 Go to previous messageGo to next message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 84
Registered: March 2018
Member
In both versions of Eclipse, under the tab "Window" there is no item called "Preferences." I found "Preferences." under "Eclipse."

Thanks. It looks like I may be able to reset "Installed JREs" to get version eight.

[Updated on: Mon, 12 November 2018 08:11]

Report message to a moderator

Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798088 is a reply to message #1798068] Mon, 12 November 2018 09:45 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29649
Registered: July 2009
Senior Member
Yes, sorry, on the Mac the Preferences are in "the standard Mac location" under the "Windows" main menu item as is the case on Linux and Window.
Re: Using Eclipse Version: 2018-09 (4.9.0) can't launch JAR [message #1798119 is a reply to message #1798088] Mon, 12 November 2018 23:19 Go to previous message
Patrick Moran is currently offline Patrick MoranFriend
Messages: 84
Registered: March 2018
Member
Thanks for all the help. I've given up on Photon. There is also a big problem with Javax that the Java developers appear to have known but ignored. I have seen this problem too. Code that worked fine using Oxygen fails when run using Photon.
See the following. This is a known problem, and it seems that the solution is to go back to Oxygen.
https://stackoverflow.com/questions/52686025/upgrade-to-jdk-10-and-encountered-extensive-compile-errors-in-eclipse
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900912

I now have Oxygen working on the new Mac, and have recovered the ability to produce a runnable JAR. Photon simply can't make one.

[Updated on: Mon, 12 November 2018 23:42]

Report message to a moderator

Previous Topic:MADT and standard eclipses
Next Topic:Converting Java projects to Macintosh executables
Goto Forum:
  


Current Time: Tue Nov 13 18:18:40 GMT 2018

Powered by FUDForum. Page generated in 0.03878 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top