Isac Active Member Licensed User Longtime User Dec 26, 2016 #1 I would like to retrieve the IP of my PC. with java I imported this library: B4X: import java.net.*; with java I am managed in this way: B4X: Button btnNewButton = new Button(shell, SWT.NONE); btnNewButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { InetAddress ip= InetAddress.getLocalHost(); JOptionPane.showMessageDialog(null,ip.getHostAddress()); } catch (UnknownHostException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } how can I do with b4j? thank you Attachments test.PNG 28.8 KB · Views: 292
I would like to retrieve the IP of my PC. with java I imported this library: B4X: import java.net.*; with java I am managed in this way: B4X: Button btnNewButton = new Button(shell, SWT.NONE); btnNewButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { InetAddress ip= InetAddress.getLocalHost(); JOptionPane.showMessageDialog(null,ip.getHostAddress()); } catch (UnknownHostException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } how can I do with b4j? thank you
EnriqueGonzalez Expert Licensed User Longtime User Dec 27, 2016 #2 you can use a very similar method like the one here: https://www.b4x.com/android/forum/threads/b4j-how-to-ping.37755/#content Just look at the 4th (Daestrum) post. Upvote 0
you can use a very similar method like the one here: https://www.b4x.com/android/forum/threads/b4j-how-to-ping.37755/#content Just look at the 4th (Daestrum) post.
jmon Well-Known Member Licensed User Longtime User Dec 27, 2016 #3 You can do it several ways: With jNetwork: B4X: Dim local As ServerSocket local.Initialize(1, "") Dim Host As String = local.GetMyIP with jAWTRobot: B4X: Dim Host As String = AWT.SystemHostNameAndIPAddress You can also parse a command line (ipConfig / ifConfig) result with jShell. Upvote 0
You can do it several ways: With jNetwork: B4X: Dim local As ServerSocket local.Initialize(1, "") Dim Host As String = local.GetMyIP with jAWTRobot: B4X: Dim Host As String = AWT.SystemHostNameAndIPAddress You can also parse a command line (ipConfig / ifConfig) result with jShell.