2014年5月17日 星期六

Cannot load web pages powered by java anymore?

I got this issue for months after upgrading to Java JRE 7 update 55.

The syndrome is that all java web pages,
including web banks, and even android SDK manager,
cannot be loaded properly after upgrading to the latest JRE.

My working device is using Windows 8, and I think it matters.

And it's difficult to find a solution after copy-pasting the exceptions directly to google!
The exception was too general, leading to lots of useless web pages.

In short, this issue can be solved simply by setting system-wide environment variables

_JPI_VM_OPTIONS=-Djava.net.preferIPv4Stack=true
JAVAWS_VM_ARGS=-Djava.net.preferIPv4Stack=true

Relaunch browsers, and you will see everything works fine again!

As of how to set system-wide environment variables in Win8 is a common system administrator task that can be answered by Google,
or you may refer to the official Java document
http://docs.oracle.com/javase/tutorial/essential/environment/paths.html


Similarly, for running java programs in command line, use

java -Djava.net.preferIPv4Stack=true CLASSNAME


The Android SDK Manager can be treated similarly.

Update tools/android.bat by adding the flag to the latest line so that it looks like

call %java_exe% -Djava.net.preferIPv4Stack=true ...

Then, the GUI interface also works fine :)