The objective of this post talk about my little “adventure” in resolving the fatal Java error that prohibits running Java application.
You use to have the Java applications and Java IDE on your Windows-based system working then one fine day, out of unknown reason, all the Java application and plug-in in the IDE cease to work. Worse, no error message and the application just silently fail to run. Oh, your first thought is that this shouldn’t happen because it is not even April’s fool day or Monday’s blue because today is Wednesday in July. So your first reaction is to re-install the Java SDK or runtime assuming that they might have been damaged. However just before re-installing you confirm that the SDK/runtime is indeed the main problem so you test-run some command in Window command console. jar.exe command run fine but running java.exe on directory other it’s bin directory produce the infamous
Error occurred during initialization of VM
What so damaging about this problem is the some plugins like Android and Grails in Intellij become non-functional as well. You know why very soon.
So here I go trying to resolve the issue. Running Java.exe produce error in other directories (since the SDK’s bin is added to path.)
However running in it’s bin directory, it runs fine.
So your immediate conclusion is that somehow the path is the main culprit. However looking at the path output, there is nothing very harmful on the path after all it is just windows path and the JavaFX path which should hardly cause any problem since it is the “buddy” of Java, it should play well.
Still the investigation continue and use a “divide and conquer” approach. Next you reset the path to using only the Java’s bin directory by using:
and voila, the problem goes away now !
Now the last thing to do is to check which directory on the path is causing the problem. So the main surprise turn out that Windows directory is the major culprit.
Still curious on how Windows directory can be the source of problem, the only way such error can happen is that the same file (java.exe) might have existed in Windows and overshadowing the one in Java’SDK hence causing the problem. Remember that when a file is executed, the one in foremost directory on the path will be run.
The good news is that it is nothing supernatural or magical but the bad news is that the Windows directory is the “protagonist” . From file search, it can be concluded that somehow certain mischievous program is copying some crucial java files into Windows directory which are stored in path, and so unless the java’s bin is the foremost in the path, one will bound to get the error. The error occurs because Java.exe or other Java executable expect some support files and directories to be found but obviously could not find it in Windows directory. Running the java.exe in its bin directory will not produce error because Windows will use the current directory to which the file is run first before searching for it in the path.
Removing those java files in the Windows cure the problem. However, the next step is to find out the application that copy those files which will surely be more challenging and adventurous than this.
So what is exactly very frustration about this path issue is that it result in very-hard-to-find problem that could result in very expensive effort. For example, one will re-reinstall Java’s SDK ample times and yet the problem persists simply because of file overshadowing. That to say any directory in the path could be the victim not just Windows’.
So here end the “adventure” and hope anyone reading this can learn through this experience .