This week's book giveaway is in the Cloud forum.
We're giving away four copies of Terraform in Action and have Scott Winkler on-line!
See this thread for details.
Win a copy of Terraform in Action this week in the Cloud forum!

andrew mcnamara

Greenhorn
+ Follow
since Apr 15, 2019
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by andrew mcnamara

Hello internet,

I went ahead and dug into swing to find out if I could run a swing project on Pi with NO OTHER jars.

It turns out that Swing is a far better option for Pi than javaFx. A swing GUI will run in a window (java FX runs with a black boarder, blacking out the desktop) and requires no changes to raspian whatsoever (java fx requires many additional jars and some tweaks the likes of which the most seasoned googler could only image).

Thanks for your input.
2 years ago
I can set the position of the stage in the code, yes. I'd like to be able to drag the window across the desktop. Both are important as a matter of elegance.
2 years ago
I suppose that would work as long as I can still use my other java classes. I am reluctant to get too far outside my limited knowledge if there's a solution closer to conventional java. Would you suggest a webpage or video where I can look into it? Thanks.
2 years ago
Hello all,

I'm looking to design a simple GUI for a java program on raspberry pi. I am not pleased with the drawbacks of JavaFX on pi.

I'd like to consider Swing or other GUI tools for java on the pi if and only if:

1) I don't need to download extra jars to get a swing program running. (libraries are no problem)
2) Swing GUI windows can actually run in windows. JavaFX "windows" cannot be re-positioned or closed. All desktop outside the window is black. Not ideal.

The internet is very sparse on details here. Any recommendation welcome. Python would be a better option for sure, but the guts of my program are already running in java.

Thanks,
2 years ago
Hello all,

Many thanks for your responses. Yes, I see now that this was purely a class path issue. I was able to resolve it last night by building a fat jar:

https://stackoverflow.com/questions/18451052/how-to-include-jars-in-lib-into-project-jar-file-in-netbeans/30172972

Your advice here led me to the solution.

Thanks again,
2 years ago
@ Paul : The Java file with the main method is called GUI.java, but the package name in NetBeans where all the source files are is simply “<default package>” (I know, bad move on my part, this is from a while ago). Is there a way we can tell that to the terminal (i.e. something like WITPhoneHome.GUI or main.GUI) since it won’t recognize “<default package>”?

$ java -classpath /home/pi/Desktop/Jars/ <default package>.GUI
-bash: default: No such file or directory
2 years ago
I was still using that version of the java command, yes.

What is a simple way to run our jar on the Pi through terminal while including multiple 3rd-party library jars in the class path?
2 years ago
It's possibly a netbeans problem, but I assume I'm doing something wrong. I also tried to put the jars directly in the runnable jar and running on the pi from terminal. That resulted in the same errors.

To apply libraries, I right click the project folder --> properties --> Libraries (under "categories") --> add (the "+" sign) compile-time class path jar

Please somebody tell me I'm a dummy and I've done something simple and incorrect.

2 years ago
Precisely the same error results when I run with the jars in the WITPhoneHome folder.
2 years ago
When I compile over SSH to the Pi, netbeans creates a runnable jar on the Pi in the directory:

home/pi/NetBeansProjects/WITPhoneHome/dist/WITPhoneHome.jar

I try to put the apache jars inside the WITPhoneHome folder, but that doesn't work. Putting things in the dist folder also didn't work. Any other ideas?

Many thanks for your help.
2 years ago
I only have Netbeans on the macbook. From netbeans on the macbook, I compile on the pi over SSH.
2 years ago
No, that apache jars are not in the runnable jar. Any advice as to where I should put them?

Many thanks for your help.
2 years ago
The project folder is the project directory on netbeans on my work station. I am compiling the project to pi in netbeans over SSH. I should have mentioned this.

Is it possible to add it to the class path so that all library jars are included in the jar which runs on the Pi?
2 years ago
I get this monolith to console:



Connecting to 10.18.20.119:22
cmd : cd '/home/pi/NetBeansProjects//WITPhoneHome'; '/opt/jdk1.8.0_211/bin/java'  -Dfile.encoding=UTF-8   -jar /home/pi/NetBeansProjects//WITPhoneHome/dist/WITPhoneHome.jar
Exception in thread "JavaFX Application Thread"
java.lang.NoClassDefFoundError: org/apache/commons/net/telnet/TelnetClient
at Path.<clinit>(Unknown Source)
at GUI.callConstructors(Unknown Source)
at GUI$5.lambda$handle$0(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8411)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3761)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3489)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2498)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:352)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:275)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$353(GlassViewEventHandler.java:388)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:391)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:387)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.monocle.MonocleView.notifyMouse(MonocleView.java:119)
at com.sun.glass.ui.monocle.MouseInput.notifyMouse(MouseInput.java:314)
at com.sun.glass.ui.monocle.MouseInput.lambda$postMouseEvent$101(MouseInput.java:227)
at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:93)
at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:52)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.net.telnet.TelnetClient
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 53 more
"
2 years ago

Matt Wong wrote:if you want to use an external lib in your application you just have to add it to the classpath - where this lies in the filesystem is up to you



The library jars are imported into the project folder. They must be in the class path then, right?
2 years ago