IPv6 v IPv4 in Java

It turns out that if your Java app is getting IPv6 addresses back from InetAddress.getLocalHost().getHostAddress() you can use flags to the Java VM to control this behaviour

-Djava.net.preferIPv4Stack=true

if you only want IPv4 addresses returned, or

-Djava.net.preferIPv6Stack=true

if you need to test your code against IPv6 addresses. These flags are only valid when passed to the JVM when it’s started up (ie they can’t be changed once the App’s running).

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Ma.gnolia
  • NewsVine
  • Reddit
  • RawSugar

Related posts:

  1. Java Update 1 kills QuickTime for Java Apple has released (via Software Update) “Java for Mac OS...
  2. dscacheutil is command of the day Having recently changed ISP, my command of the day is...
  3. QuickTime for Java doesn’t let you access B-frames From a a post to the QuickTime-Java mailing list, Apple’s...
  4. Java 6 on Leopard Fans of Java 6 who want to be able to...
  5. Building Universal Java App Bundles on Mac OS X So, if you’ve got a Java application bundle that’s built...

Related posts brought to you by Yet Another Related Posts Plugin.

Leave a Reply

  • JoyOfTech

  • Recent Comments

  • Was it useful? Was it funny? Was it weird? Please tip the author!
  • airport apple apple_store apple_tv apple_university_consortium auc Australia Backup blackberry cocoa dantz emc fink Firewire flickr game iMac iPhone iphone_3g iphone_3gs iPhoto iPod ipod_nano ipod_touch iTunes java job keynote leopard Mac MacBook macbook_air macbook_pro macjob MacWorld macworld_2008 mac_os_x music retrospect safari Security steve_jobs time_capsule time_machine WWDC
  • Pages

  • Archives

  • Meta