t-oster / VisiCut

A userfriendly tool to prepare, save and send Jobs to Lasercutters
https://visicut.org
Other
230 stars 114 forks source link

java.lang.NoClassDefFoundError: com/apple/eawt/PreferencesHandler #488

Closed hrasadi closed 5 years ago

hrasadi commented 5 years ago

I cannot open platform-independent app (v.1.8-51). I have Java HotSpot(TM) 64-Bit v. 11.0.1. Error is:

java.lang.NoClassDefFoundError: com/apple/eawt/PreferencesHandler at com.t_oster.visicut.gui.VisicutApp.startup(VisicutApp.java:77) at org.jdesktop.application.Application$1.run(Application.java:171) at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85) at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740) at com.t_oster.visicut.gui.VisicutApp$1EventQueueProxy.dispatchEvent(VisicutApp.java:131) at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203) 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) Caused by: java.lang.ClassNotFoundException: com.apple.eawt.PreferencesHandler at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 16 more

t-oster commented 5 years ago

Looks like some apple specific stuff has been removed from Java 11. I will try to fix that. Until then you could try with Java 8

hrasadi commented 5 years ago

Thanks for verifying the problem. I will fallback to Java 8 for the time being.

t-oster commented 5 years ago

Looks as If there is a new API http://openjdk.java.net/jeps/272

koffiris commented 5 years ago

screen shot 2019-01-27 at 11 20 24 Hi, I also have trouble installing VisitCut. I use (oracle)Java 8 Update 201 (build 1.8.0_201-b09) Any idea why it is not working?

t-oster commented 5 years ago

Strange, I have it working with exactly the same oracle version on my virtual OS X. I will provide a pre-packaged version including the JRE soon. Are you sure it is running with that version? maybe you have two java versions installed. Try running from the command line, first java -version and then in the unzipped version "java -jar Visicut.jar"

koffiris commented 5 years ago

I got the version from the Java control panel that I can open via the system preferences. With some help I have used the terminal. I get:

$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)
$ cd Downloads/VisiCut.app/Contents/Resources/Java
$ java -jar Visicut.jar 
java.lang.NoClassDefFoundError: java/nio/charset/StandardCharsets
    at com.t_oster.visicut.managers.FilebasedManager.readObjectFromXmlStream(FilebasedManager.java:254)
    at com.t_oster.visicut.managers.FilebasedManager.readObjectFromXmlFile(FilebasedManager.java:272)
    at com.t_oster.visicut.managers.PreferencesManager.loadPreferences(PreferencesManager.java:349)
    at com.t_oster.visicut.managers.PreferencesManager.getPreferences(PreferencesManager.java:291)
    at com.t_oster.visicut.gui.VisicutApp.initialize(VisicutApp.java:103)
    at org.jdesktop.application.Application$1.run(Application.java:170)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
    at java.awt.EventQueue.access$400(EventQueue.java:82)
    at java.awt.EventQueue$2.run(EventQueue.java:676)
    at java.awt.EventQueue$2.run(EventQueue.java:674)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:685)
    at com.t_oster.visicut.gui.VisicutApp$1EventQueueProxy.dispatchEvent(VisicutApp.java:131)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.lang.ClassNotFoundException: java.nio.charset.StandardCharsets
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
    ... 21 more
$ 
t-oster commented 5 years ago

So in the terminal you have Java 1.6 (aka Java 6). Try to uninstall that,maybe then 1.8 is used. Or wait for my pre-packaged version

koffiris commented 5 years ago

I do not know how to uninstall so I'll wait for now... there are more people now learning to use the lasercutter and having trouble installing visicut... so I hope I can make them happy with an update soon ;-)

t-oster commented 5 years ago

You dont need to wait, it's done. Please Test the latest release

t-oster commented 5 years ago

The one for OSX

koffiris commented 5 years ago

Super! Thnx a lot, it works :-) I will let the others know...

t-oster commented 5 years ago

I'm glad to have that tested. I also have (temporary) this version: http://download.visicut.org/VisiCut.app.zip which includes JRE8. So you would not even have to have java installed. Please test this also on Macs without Java if you can. However this is not yet integrated in the build process, so for new updates, stick to the official version

koffiris commented 5 years ago

Thnx, I’ll send it to others... but since I do not know how to deinstall Java I can not test it. I’m sorry...

All the best, Iris

Op 31 jan. 2019 om 08:11 heeft Thomas Oster notifications@github.com het volgende geschreven:

I'm glad to have that tested. I also have (temporary) this version: http://download.visicut.org/VisiCut.app.zip which includes JRE8. So you would not even have to have java installed. Please test this also on Macs without Java if you can. However this is not yet integrated in the build process, so for new updates, stick to the official version

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dclaar commented 5 years ago

I still see this with 1.8-73-g3f4e2a4c, mac 10.14.5, java version "10.0.1" 2018-04-17

Screen Shot 2019-05-28 at 4 16 31 PM

setting JAVA_HOME to 1.8 and running it from the command line works OK.

t-oster commented 5 years ago

Yes, VisiCut does not run with Java 1.10. Can you investigate if it is possible to specify that in the info.plist file, so it works without setting JAVA_HOME? does the version with JRE included http://download.visicut.org/VisiCut.app.zip work?

dclaar commented 5 years ago

I'm asking around to find out how to modify info.plist: I'm not really a mac person. :) I'll respond back if I find out anything.

I added the comment because the issue was closed (and I thought, fixed). And yes, the version with the JRE included works fine, thanks!

dclaar commented 5 years ago

I haven't found a definitive Info.plist answer yet, but...

Maybe someone with more than 1.x version can run this? (9 and above don't start with 1.):

/usr/libexec/java_home -v 1.

I think that it should return the latest 1.x version (It returns the location of 1.8 for me; but I only have 1.8, 9, 10, 11 on my system, and installing older ones is...discouraged).

Then Visicut.MacOS can use that:

#!/bin/bash
DIR="$( cd -P "$( dirname "$0" )" && pwd )"
/usr/libexec/java_home -v 1. --exec java -Xms256m -Xmx2048m -jar "$DIR/Visicut.jar" --singleinstanceport 6543 "$@"
dclaar commented 5 years ago

Assuming that java 9 doesn't work, one solution is to replace VisiCut.app/Contents/MacOS/JavaAppLauncher with the following.

#!/bin/bash -x
result=`/usr/libexec/java_home -v 1. 2>&1 >/dev/null`
if [[ $? -ne 0 ]];then
  osascript -e 'display notification "'"${result//\"/}"'"'
  exit 1
fi
DIR="$(dirname $( cd -P "$( dirname "$0" )" && pwd ))"
cd ${DIR}/Contents/Resources/Java
/usr/libexec/java_home -v 1. --exec java -Xms256m -Xmx2048m -jar "${DIR}/Java/Visicut.jar" --singleinstanceport 6543 "$@"

Note that it could be further spiffed up to grab JVMOptions from Info.plist, but maybe that's overkill

$ /usr/libexec/PlistBuddy -c "Print JVMOptions" /Applications/VisiCut.app/Contents/Info.plist
Array {
    -Dapple.laf.useScreenMenuBar=true
    -Xdock:name=VisiCut
    -Xms128m
    -Xmx1048m
    -splash:splash.png
}
dclaar commented 5 years ago
JVMOptions=$(/usr/libexec/PlistBuddy -c "Print JVMOptions" "/Applications/VisiCut.app/Contents/Info.plist" |    awk '/-/{args=args $0};END{print args}')