How to remotely debug a javaFX program executed by Raspberry Pi from Windows 10-From environment construction to debug execution ②-

First, put the GitHub repository https://github.com/kamoshika9999/HelloRemote.git

Introducing javaFX to Raspberry Pi

  1. The normally included JDK is java-11-openjdk-armf. Since javaFX is excluded in this version, a customized JDK is introduced by the following method.
cd /home/pi
wget https://download.bell-sw.com/java/13/bellsoft-jdk13-linux-arm32-vfp-hflt.deb
sudo apt-get install ./bellsoft-jdk13-linux-arm32-vfp-hflt.deb
sudo update-alternatives --config javac
sudo update-alternatives --config java

Introduction of samba

  1. Download and install the main unit
sudo apt-get install samba
  1. Start nano of text editor
sudo nano /etc/samba/smb.conf
  1. Added to the last line
[raspberry_pi]
comment = Share
path = /home/pi/samba
public = yes
read only = no
browsable = yes
force user = pi
  1. Create a samba folder in / home / pi
sudo mkdir /home/pi/samba
  1. Service start * It will be started automatically when Raspberry Pi starts next time.
sudo systemctl restart smbd

Windows 10 side settings

  1. From "Turn Windows features on or off", check "SMB 1.0 / CIFD Client" and restart. image.png
  2. Enter \ 192.168.9.112 in Explorer and see if you can see the raspberry_pi folder

Prepare xml file for Ant build

  1. Right-click HelloRemote in Eclipse Package Explorer "Export"-[Java]-[Executable JAR file]-"Next" image.png

Launch configuration Main-HelloRemote Export destination Raspberry Pi samba folder + file name "fxtest.jara" * File name is decided appropriately Check Save as Ant Script The location is the same as the workspace of the project, and the file name is build.xml. image.png 3. When you press Finish, a warning will appear, but it is OK as it is image.png 4. Right-click on a blank space in Package Explorer to refresh image.png 5. Right click on build.xml and open it with-ANT editor image.png

  1. Change build.xml to the following The file path part needs to be rewritten
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="remotedebug" name="Create Runnable Jar for Project HelloRemote">
    <!--this file was created by Eclipse Runnable JAR Export Wizard-->
    <!--ANT 1.7 is required                                        -->
    <!--define folder properties-->
    <property name="dir.buildfile" value="."/>
    <property name="dir.workspace" value="${dir.buildfile}/.."/>
    <property name="dir.jarfile" value="//192.168.9.112/raspberry_pi"/>

	<property name="raspberrypi" value="192.168.9.112" />
	<property name="raspberryfolder" value="/home/pi/samba" />
	<property name="username" value="pi" />
	<property name="password" value="raspberry" />
	
	<target name="create_run_jar">
        <jar destfile="${dir.jarfile}/fxtest.jar" filesetmanifest="mergewithoutmain">
            <manifest>
                <attribute name="Main-Class" value="application.Main"/>
                <attribute name="Class-Path" value="."/>
            </manifest>
            <fileset dir="${dir.buildfile}/bin"/>
            <zipfileset excludes="META-INF/*.SF" src="C:/OPENCV3/pleiades-4.8/pleiades/eclipse/plugins/org.eclipse.fx.ide.css.jfx8_3.3.0.201805280700.jar"/>
        </jar>
    </target>
	
	<target name="remotedebug" depends="create_run_jar">
		<echo>"Starting ${raspberrypi}:${raspberryfolder}/${jar.filename} in debug mode"</echo>
		<sshexec trust="true" host="${raspberrypi}" username="${username}" password="${password}" failonerror="true" usepty="true" command="DISPLAY=:0 java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=*:4001,suspend=y -classpath ${raspberryfolder} -jar ${raspberryfolder}/fxtest.jar" />
	</target>
</project>

6-1. Explanation of the contents "Default =" remotedebug "" specifies the target to be executed last

<project default="remotedebug" name="Create Runnable Jar for Project HelloRemote">

"Target name =" remotedebug "depends =" create_run_jar "" depends on the target to be executed before this target In other words, the executable jar file is created first and deployed to Raspberry Pi.

<target name="remotedebug" depends="create_run_jar">

The part that executes commands with ssh using jsh 2 points DISPLAY =: 0 Nothing is displayed without this specification address = *: 4001 *: means access from any host. 4001 is a port number and can be changed if there is space

<sshexec trust="true" host="${raspberrypi}" username="${username}" password="${password}" failonerror="true" usepty="true" command="DISPLAY=:0 java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=*:4001,suspend=y -classpath ${raspberryfolder} -jar ${raspberryfolder}/fxtest.jar" />
</target>
  1. Set jsch to classpath to download. You can see the link as you scroll image.png image.png

Download 7-1.jsch-0.1.55.jar and save it in the applicable folder

7-2. Right-click HelloRemote and import image.png 7-3. General-Select File System and Next image.png Check 7-4.jsch-0.1.55.jar and complete image.png 7-5. Make sure you have jsch-0.1.55.jar in Package Explorer image.png 7-6. Right click on build.xml and run-configure external tools image.png 7-7. Click the new icon after selecting ant build image.png 7-8. Select the user entry on the "Classpath" tab and click the Add JAR button image.png 7-9. Expand the tree, select jsck-0.1.55.jar and click the OK button image.png 7-10. Added to classpath image.png 8. Run Ant build Press the execute button. If you see the following on the console, you are successful image.png 8-1. You can change the source and execute it from the icon from the second time onwards image.png

If you do an ANT build, you can execute "build-> deploy to Raspberry Pi-> standby in remote JVM" in one shot, which is very convenient. The introduction is long, but if you do not do this, you will lose a lot of time There is a way to work with Maven, but it will be another opportunity

Run remote debugging

  1. Right-click HelloRemote and select "Debug"-"Debug Configuration". image.png
  2. After selecting the remote Java application, click the new configuration icon image.png
  3. IP address of Raspberry Pi to host Port number specified in build.xml for port Check Allow remote VM termination Debug image.png
  4. You can do it like this. The terminal is not displayed on the Raspberry Pi side
  1. Breakpoint test Make sure that setting a breakpoint in the onTestBT method and pressing Button will switch the perspective to debug and pause image.png

Next appointment

Explain GPIO control of Raspberry Pi Mainly how to use PI4J

2020.0727 kamoshika It has nothing to do with this article, but ... I'll post a link to the main channel https://www.youtube.com/channel/UCbtzwsQhTuUzW3ERoBSYZDw/

Recommended Posts

How to remotely debug a javaFX program executed by Raspberry Pi from Windows 10-From environment construction to debug execution ①-
How to remotely debug a javaFX program executed by Raspberry Pi from Windows 10-From environment construction to debug execution ②-
How to link Rails6 Vue (from environment construction)
How to run javafx with Raspberry Pi Posted on 2020/07/12
How to Burning a Install Disk of Windows from Ubuntu
How to set up SSH from scratch without connecting a monitor or keyboard [Raspberry Pi, Ubuntu]
How to develop from VScode in a remote destination environment or a remote destination container environment
[Introduction to Java] How to write a Java program
A program that calculates factorials from 2 to 100
Build a WAS execution environment from Docker
[Java] How to measure program execution time
[First environment construction] I tried to create a Rails 6 + MySQL 8.0 + Docker environment on Windows 10.
I wrote COBOL ~ Execute the program from the environment construction by Ubuntu and GnuCOBOL ~