Java & Windows (7): Reliably getting IPv4 netmask?

I've run into a known bug with Java 6 on Windows. My understanding is that the normal way to get the netmask is to look up the network prefix length and do some bit shifts. The problem is that on Windows the prefix length is often returned incorrectly, so we get a 128 when we should get a 24 or 20.
At http://stackoverflow.com/questions/1221517/how-to-get-subnet-mask-using-java, it is suggested to put -Djava.net.preferIPv4Stack=true on the Java command line. Unfortunately, on Windows 7, adding that as either a VM parameter or on the Java command line seems to have no effect.
(a) Does anyone know any OTHER work-arounds for this problem that might still work on Windows 7?
(b) Alternatively, is there an entirely different way to get the netmask that is reliable?
Thanks!

On CodeRanch, someone explained that I had made an etiquette error by not listing the other places where I have asked this question.
Here they are:
http://stackoverflow.com/questions/9299566/java-windows-7-reliably-getting-ipv4-netmask
http://www.codeguru.com/forum/showthread.php?t=521196
Java & Windows (7): Reliably getting IPv4 netmask?
http://www.coderanch.com/t/567601/sockets/java/Java-Windows-Reliably-getting-IPv
I am actively monitoring each site.
Explanation: I first posted on StackOverflow, but I didn't get a response. Usually I'm amazed at how quick people are to respond on that site, so I'm assuming the lack of response is due to this being a hard problem. I've been digging pretty hard on this, and most I've seen is some suggestions as to how to fix the problem in Java itself, but no work-arounds that actually work for me. Thus, I was motivated to post in multiple places in the hope that I'd get some help somewhere.
Sorry for the confusion.
Edited by: 915022 on Feb 16, 2012 8:55 AM
Edited by: 915022 on Feb 16, 2012 9:01 AM

Similar Messages

  • Get Native Java Window using Java Access Bridge 2.0.1 & Java 1.6 and above

    I want to get the native java window (Like Java Monkey Application and Java Ferret Application) using java only, for that I tried different ways/options but unable to get the native java window and perform actions on that.
    It would be really great if you could guide me for that. I am still unable to start the Java Access Bridge.
    Please let me know the steps to get native java window using Java Access bridge and JDK 1.6.20.
    Also Note that, As per your previous suggestion, I tried to search and call initializeAccessBridge() and shutdownAccessBridge(), But unable to succeed it. I did not find such method in Accessbridge.jar.
    Please help me out.
    Best Regards

    You might want to check out this thread:
    Java Access Bridge and JRE 1.6
    If you have Java 6, you'll need to manually install Java Access Bridge 2.0.1. The JAB 2.0.2 installer for Java 6 is also available as a beta:
    http://jdk6.java.net/6uNea.html

  • How get IPv4 instead of IPv6 (class NetworkInterface)

    Hello! I've written java code:
    nets = NetworkInterface.getNetworkInterfaces();
    NetworkInterface selInterface = Collections.list(nets).get(curIndex);
    ips = selInterface.getInetAddresses();
    InetAddress addr = Collections.list(ips).get(0);
    String str = addr.getHostAddress();
    And I obtain IPv6, for example: fe80::20c:29ff:fe2d:a225. How can I get IPv4 or transform IPv6?
    p.s. this problem is observed only in Linux, on windows machine program works good.

    Note : IPV4 address and IPV6 address are unrelated (i.e. no conversion from one to another)Note: this is not correct. Some IPv6 address formats are explicitly provided to act as representations of IPv4 addresses.

  • Is there a way for java plug-in to get the browser login authentication

    I have an applet that is loaded from a password protected html page. I use java plug-in with the applet.
    When I try to read this page I get the browser window asking for password and username. So far so good.
    Then I log in successfully and starts using the applet.
    If the applet wants to access pages on the same PW protected area, I have to give the plug-in PW and UN.
    My question is then:
    Is there a way that java plug-in can get hold of the login information that the browser has obtained? (So that I wont have to give the same information twice)
    I thought the answer would be no, but then I started experimenting with https and found out that if I use the same scenario as above, except from that I give a certificate to the browser before the first login, then the plug-in will get certificate info from the browser, and it wont promt me for UN and PW either!
    When it is possible for the plug-in to obtain certificate info and login info from the browser then it should be possible just to get the login info with ordinarily http?

    bump

  • Java Windows Misbehaving

    I'm not sure where I should be posting this question about Java, but since the problems started after updating the OS, I'm asking it here.
    Since upgrading to OS 10.4.7 a couple of weeks ago and installing the latest Java files, I get weird behavior when using any of the three colored buttons at the top left of any Java window.
    If I click on the red button, the window will minimize into the dock, as if I had hit the yellow button.
    If I hit the yellow button, the window will minimize correctly BUT it will minimize other, non-Java windows as well.
    At times (I can't figure out the pattern) the window will close, and/or other windows will close, Java or not.
    I use Firefox 1.5.0.6. Is this a Firefox bug or a Java bug?
    Thanks for your help!

    bump
    I need your help, please.

  • Openning a new java window.

    Hi there,
    I want to create an applet that will open a new java window that will run another class but will get the data from the first class, how do I do that?
    Thanks

    Actually I don't know what newWin class is. Sounds like you don't extend Frame from that. So you should make a new class that extends Frame, and has a constructor that can take a newWin object.
    public class MyFrame extends Frame {
      private newWin win;
      public Frame(newWin win) {
        super("My Frame");
        this.win = win;
    }And then your applet would have this code
    newWin win = new newWin(); // I don't know what the constructors are!
    final MyFrame frame = new MyFrame(win);
    Button submitButton = new Button("Submit");
    submitButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) { // user pressed the submit button
        frame.show();
    });

  • Java windows slip under menu bar, how to move?

    Hi, I have accidently dragged some Java windows beneath the (transparent) menu bar.
    Safari browser windows do not slip under the menu bar, but those created by a Java application can slide beneath it, up to the edge of the screen...just far enough to make accessing their title bars impossible. I'm able to resize the Java windows by dragging their accessible edges but I am unable to click on their title bars in order to drag them back down beneath the menu bar.
    How can I click upon title bars or resize these windows to lower them in desktop space, so their title bars are lower than the menu bar? I am currently unable to drag or click upon their obscured title bars to move these windows. Is there another way to move windows without clicking upon their title bars?
    thanks

    apparently there is a third party app called windowsmover or something like that
    do a google search for "windows mac os move shortcut keyboard"
    to answer my own post

  • When installing itunes on my windows XP I get an error message "Service Apple Mobile Device"

    When installing iTunes on my Windows XP I get an error message "Service Apple Mobile Device (Apple Mobile Device) failed to start.  Verify that you have sufficient privileges to start system services".  I don't know what this means and I do not know how to resolve it.  Can you advise please?

    Solving the iTunes Installation Problems in Windows
    1. Apple has posted their solution here: iTunes 11.1.4 for Windows- Unable to install or open - MSVCR80 issue.
    2. If the Apple article does not fully resolve the problem for you, then try Troubleshooting issues with iTunes for Windows updates - MSVCR80.
    iTunes 11.1.4 for Windows- Tips for Unable to install or open

  • HT201413 I am having a problem updating itunes to the latest version on my windows xp i get the error message 126 and the sign that says this application has failed because MSVCR80.dll was not found.

    I am having a problem updating itunes to the latest version on my windows xp i get the error message 126 and the banner that says this application has failed because MSVCR80.dll was not found. anyone have a fix suggestion? thanks

    Click here and follow the instructions.
    (98724)

  • I have iTunes open in Windows XP and get an error 45048 message when I try to update apps thru the store. How can I fix this? I have reinstalled iTunes twice.

    I have iTunes, latest version, open in Windows XP and get an error 45048 message when I try to update apps thru the store. How can I fix this? I have reinstalled iTunes twice but problem continues.

    Try contacting iTunes via email to check if there is an issue with the account. go to apple.com/support/itunes
    Click on iTunes Store account and billing and select inquiries. On the right side click on "email us".
    Before doing that trying viewing your account information first. Open the iTunes on you mac, look at the menu and select store and select view my account. Try removing the card (this is only applicable if you don't have a pending charges with iTunes) and hit done. Sign out, quit iTunes and sign back in and try updating the apps again.

  • I have itunes in windows xp, but my ipod touch has updated version of itunes. Windows xp cannot get updated itunes. I am having difficulties transferring my music into my computer. Does any one have an idea how to do it?

    I have itunes in windows xp, but my ipod touch has updated version of itunes. Windows xp cannot get updated itunes. I am having difficulties transferring my music into my computer. Does any one have an idea how to do it?

    iTunes 11 is compatible with
    Windows System Requirements
    PC with a 1GHz Intel or AMD processor and 512MB of RAM
    Windows XP Service Pack 2 or later, 32-bit editions of Windows Vista, Windows 7, or Windows 8
    Try:
    Trouble installing iTunes or QuickTime for Windows

  • Opening a Java Window from a jsp page on the client side

    Hi all,
    Thanks in advance to all who could help me for this problem.
    I've written some jsp pages. In one of them, I open a new Java Window,
    which is a simple Java Frame. If I test this directly on the Tomcat
    server, everything works well.
    But when I call the jsp page through a web browser of a distant client
    (normal use), and when I want to see the java window, no window pops
    up. It appears that the Java Window pops up on the server, and not on
    the client side, which is what I wanted.
    Could someone tell me how to make the Java frames appear on the client
    side ? (Is it linked to the code or to the configuration of Tomcat ?)
    Thanks in advance,
    Alexis.

    JSP always run on the server. On the client you only see the results.
    But you can use applets on the client side: http://java.sun.com/docs/books/tutorial/uiswing/components/applet.html

  • When i try to install itunes 10.6.3 for windows vista i get "error microsoft VC*80.CRT,type="win32",version="8.0.50727.6195".publicKey token="1fc8b3b9a1e18e3b",ProcessorArchitecture="x86"   what should i do?

    when i try to install itunes 10.6.3 for windows vista i get "error microsoft VC*80.CRT,type="win32",version="8.0.50727.6195".publicKey token="1fc8b3b9a1e18e3b",ProcessorArchitecture="x86"   what should i do?

    same problem. tried the ff fixes from microsoft but no joy
    http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/gett ing-error-message-an-error-occurred-during-the/10122022-2d88-4266-a695-6c6ddeafd 019?tab=AllReplies&page=1
    http://answers.microsoft.com/en-us/windows/forum/windows_vista-windows_programs/ windows-vista-unable-to-install-itunes-an-error/19b48df7-54c8-47f3-8854-d34118fa a79a
    http://support.microsoft.com/mats/system_maintenance_for_windows/en-us
    other ideas would be appreciated.
    cheers

  • Ipad is not being recognized by Windows..I get a Code 43 error on any USB port I try. I have rebooted, restarted, blah blah til I am blue in the face.

    Ipad is not being recognized by Windows..I get a Code 43 error on any USB port I try. I have rebooted, restarted, blah blah til I am blue in the face. This is an Ipad not an Ipad2...I can't get this thing recognized by either my desktop or laptop. It used to work...not now.
    Any ideas?

    Did you already have a look at this article?
    iOS: Device recognized in iTunes for Mac OS X

  • Windows xp pro sp2 no display in java windows

    Hi everybody,
    I have just install my new computer, windows xp pro sp2 and java 1.5 update 4, and I have this problem:
    I can't see what's inside java windows, for examples when I go throw the control panel and I want to configure java when I double click on the icon, I see the borders of the windows but nothing inside..
    Same thing with some java installer...
    I tried to unistall java 1.5 and install java 1.4 same thing...
    As any one a solution to my problem?
    thks

    OK I found why..
    But..It's strange when I put my ATI driver on normal, and not on High Quality it's working :)

Maybe you are looking for

  • Office 2013 Pro - Error Message - I cannot set Office 2013 as the default mail client

    I have a number of PCs on a single domain in the same office all running Windows 7 Pro.  Some at 64 bit and some are 32 bit depending on their age. My issue is that on upgrading from Officer 2010 Pro to Office 2013 Pro, the only application I have a

  • Screen rotation

    Hello!  I have a pearl 9105. OS 6.0 Bundle 2950 (6.6.0.236). I have a problem with screen rotation. When I go to browser, the screen won´t rotate. In the options I don´t find any options for rotate the screen. Is there any way to rotate the screen fo

  • Nokia E6 is not switching on

    Hello, I've recently bought a nokia e6 in december 2011 and I updated its software to symbian belle and a month later I restored it to default settings and it restarted but kept on tripping and switching off. Now when I try switching it on it will on

  • My Droid froze up after call

    Anyone know how to turn on the phone after screen goes black.  Seems to be frozen or something.  After a call when they hung up screen went black and now won't turn on.....Any suggestions?

  • Cost component or cost roll-up issue

    Hi This is with reference to new issue that surfaced in costing recently.  In the company I am working for cost component structure setup is like this : 1) raw material is considered as variable cost 2) activity as fixed and when it rolls-up cost of