suipaste
Posts: 17
Joined: Tue Jul 17, 2012 6:50 pm

Pi4J & GUI (swing)

Wed Jan 08, 2014 10:09 pm

Hi, I'm trying to develop an application which makes use of a java GUI framework and the Pi4J library to develop an application to control a PiFace.

I'm developing on a windows machine using netbeans (Currently looking into automatic deployment to the Pi through SSH).

So far I've built a little test program using the swing gui framework/toolkit. My next goal is to get this running on the Pi but I'm not really sure where to start. It's very easy to test on windows while developing, you just press the run button and your program pops up. However I'm scratching my head trying to get it to run on the Pi.

As I haven't set up the SSH deployment yet I'm just trying to run it off a USB stick. I assume you need to compile the java code and then run it in the same way as you do in this tutorial - http://www.savagehomeautomation.com/piface see below:

Code: Select all

cd /opt/pi4j/examples
javac -classpath .:classes:/opt/pi4j/lib/'*' -d . PiFaceExample.java

cd /opt/pi4j/examples
sudo java -classpath .:classes:/opt/pi4j/lib/'*' PiFaceExample
I'm using the same commands as above but with a different java file. It seems to compile fine but when I go to run it I get the following:

Code: Select all

 Exception in thread "main" java.lang.NoClassDefFoundError: ContentEditor (wrong name: content/          editor/ContentEditor)
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:792)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:14          2)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        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)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
Is this something to do with me not using the pi4j library in the program i'm trying to run? If someone could help me fathom what I need to do to get it to run that would be brilliant.

Stese
Posts: 32
Joined: Thu Sep 05, 2013 12:33 pm
Contact: Website

Re: Pi4J & GUI (swing)

Tue Jan 14, 2014 3:45 pm

Hey,

Without seeing a snippet from your code, there could be a few reasons why it dumps out like that.

Can I assume that the examples run ok?

When you ran your *.jar file, did you run it with sudo?
signalsandpi.wordpress.com - my pi project blog... come look! :D

suipaste
Posts: 17
Joined: Tue Jul 17, 2012 6:50 pm

Re: Pi4J & GUI (swing)

Tue Jan 14, 2014 6:11 pm

Hi thanks for the reply.

I've been working on this problem solidly for a couple of days and I've learnt a lot about compiling and running java.
I know what was wrong with this so I guess the thread can be closed / left to die. I've got some new problems but I might start a new thread for them.

Stese
Posts: 32
Joined: Thu Sep 05, 2013 12:33 pm
Contact: Website

Re: Pi4J & GUI (swing)

Wed May 21, 2014 11:56 am

I know i'm being a necromancer here,

But do you remember what you did to fix your issues?

Regards,

Stese
signalsandpi.wordpress.com - my pi project blog... come look! :D

piotr2539
Posts: 2
Joined: Thu Oct 10, 2013 7:48 pm

Re: Pi4J & GUI (swing)

Sun Aug 10, 2014 7:24 am

Hi, can you share the trick how you fix your problem? please

User avatar
Douglas6
Posts: 4738
Joined: Sat Mar 16, 2013 5:34 am
Location: Chicago, IL

Re: Pi4J & GUI (swing)

Sun Aug 10, 2014 4:31 pm

There are any number of ways to develop Java apps on a PC for the Pi. Some are discussed in this thread: http://www.raspberrypi.org/forums/viewt ... 81#p435781
I'd suggest you start a new thread describing your environment, what you've tried, and what's not working for you.

Return to “Java”