Hey guys,
I'm new to java programming, and look forward to some help with my java applet here. I've tried to follow some guides, i might have just stuck my nose too far ahead for my skill level, but can you help me out?
Im trying to receive Local and Public IP address, by running a web applet.
The code goes:
import java.applet.Applet; import java.net.*; import java.util.*; import java.io.*; public class GetIP extends Applet { public static void main(String[] args) { System.out.println("Test print"); try { System.out.println("Local IP: " + InetAddress.getLocalHost().getHostAddress()); } catch (Exception ex) { System.out.println("Error: " + ex.getMessage()); } try { String url = "http://vallentinsource.com/globalip.php"; BufferedReader br = new BufferedReader(new InputStreamReader(new URL(url).openStream())); String receive = br.readLine(); System.out.println("PublicIP: " + receive); } catch (Exception ex) { System.out.println("Error: " + ex.getMessage()); } } }