simulsys
Posts: 10
Joined: Fri Jan 04, 2013 8:36 pm

JSON Java on Pi

Tue May 16, 2017 2:42 pm

:oops:

Hi,
I have tried copying over & launching an existing Java .jar app on my Pi2. It runs, fires up the Swing forms, and the textboxes work fine. However when I activate the main process which reads the JSON files created by the selection earlier from the textboxes, it fails and errors with a verbose set of messages, the gist of which is it doesn't seem to like my JSON process for importing a parameter list?

Can anyone help please? I tried installing: sudo apt-get install java8-jdk,
getting OpenJDK8 version 1.8.0
:?:
"Toujours de l'audace" - Danton

knute
Posts: 309
Joined: Thu Oct 23, 2014 12:14 am

Re: JSON Java on Pi

Tue May 16, 2017 3:00 pm

Some actual errors would be helpful.

Do you have some sort of JSON library jar in your classpath?

simulsys
Posts: 10
Joined: Fri Jan 04, 2013 8:36 pm

Re: JSON Java on Pi

Wed May 17, 2017 7:46 am

:roll:
Yes sorry, here is some more information:

In my Netbeans library properties I have a paths to jar libraries called:
"src\~\JPL.jar"
"C:\users\~\java\json-simple-1.1.1.jar"

On startup:

Exception in thread "main" java.lang.NoClassDefFoundError: jpl/JPL
at arbiter2_3swijava.Arbiter2_3SWIJava.main(Arbiter2_3SWIJava.java:36)
Caused by: java.lang.ClassNotFoundException: jpl.JPL
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more

When trying to use app which saves to a JSON file:

loaded...
appearance
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at arbiter2_3swijava.offences.jButton3MouseClicked(offences.java:228)
at arbiter2_3swijava.offences.access$500(offences.java:25)
at arbiter2_3swijava.offences$5.mouseClicked(offences.java:100)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
at java.awt.Component.processMouseEvent(Component.java:6528)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3322)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4542)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:702)
at java.awt.EventQueue$3.run(EventQueue.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:724)
at java.awt.EventQueue$4.run(EventQueue.java:722)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

I have to confess I am a little new to Netbeans/Java, coming from .Net/Office. It seems as though I have to ship the libraries in the same directory structure with the jar file? Is this the case, please? Or what else might it be?

Many thanks, :)
"Toujours de l'audace" - Danton

knute
Posts: 309
Joined: Thu Oct 23, 2014 12:14 am

Re: JSON Java on Pi

Wed May 17, 2017 4:07 pm

simulsys wrote::roll:
Yes sorry, here is some more information:

In my Netbeans library properties I have a paths to jar libraries called:
"src\~\JPL.jar"
"C:\users\~\java\json-simple-1.1.1.jar"

On startup:

Exception in thread "main" java.lang.NoClassDefFoundError: jpl/JPL
at arbiter2_3swijava.Arbiter2_3SWIJava.main(Arbiter2_3SWIJava.java:36)
Caused by: java.lang.ClassNotFoundException: jpl.JPL
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
So this error looks like it can't find your library. I really don't know anything about Netbeans so I can't help you configure it.
When trying to use app which saves to a JSON file:

loaded...
appearance
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at arbiter2_3swijava.offences.jButton3MouseClicked(offences.java:228)
at arbiter2_3swijava.offences.access$500(offences.java:25)
at arbiter2_3swijava.offences$5.mouseClicked(offences.java:100)
This one is most likely a reference being passed to some GUI function is null. Look at line 228 in offences and see where you could be passing a null. Sometimes you can try printing the method parameters before you use them to see if they are null.
I have to confess I am a little new to Netbeans/Java, coming from .Net/Office. It seems as though I have to ship the libraries in the same directory structure with the jar file? Is this the case, please? Or what else might it be?
Many thanks, :)
You know more about it than me :-). Library jars go with the program jar. It's not like some libraries where the code gets stored in your executable. Just as a note for the problems above, the library jars need to be available for compile as well as running.

Return to “Java”

Who is online

Users browsing this forum: No registered users and 2 guests