### Inline Java Ext Library jSch

B4J UI Application - Inline Java jSch executing command on Remote Host
Reference jSch: http://www.jcraft.com/jsch/ .
Notes
Add the library JavaObject
Add the external jar jsch-0.1.53.jar to the external libraries folder
Add the external jar jsch-0.1.53 to the project attributes as #AdditionalJar: jsch-0.1.53
Important: There might be a different version in the meantime. Check the website.
Example B4J Project
Project Attributes
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
#AdditionalJar: jsch-0.1.53
#End Region
`Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private fx As JFX
Public NativeMe As JavaObject
End Sub`
`Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
NativeMe = Me
jSch_ExecuteRemoteCommandEx
End Sub`
'Example executing the "ls" command on remote host (Raspberry Pi running Raspian) using jSch
`Sub jSch_ExecuteRemoteCommandEx
Log("ExecuteRemoteCommandEx :: Start")
Dim hostcmd As String = "ls"
Dim user As String = "USER"
Dim host As String = "192.168.n.nn"
Dim pw As String = "PASSWORD"
Dim l As List = NativeMe.RunMethod("jschexeccmd", Array(user, host, pw, hostcmd))
Log("Result (Lines:" & l.Size & ")")
For i = 0 To l.Size - 1
Log(l.Get(i))
Next
Log("ExecuteRemoteCommandEx :: End")
End Sub`
If JAVA
import java.util.*;
import java.io.*;
import com.jcraft.jsch.*;
public static List

Changed: , Category: Inline Java, File: T6C201M1472.htm, ID: 1472