Saturday, December 6, 2014

Install Java without installing

How can you Install Java without actually Installing it .

You can have this need if you don't have admin rights on the machine and you urgently want to install Java and you don't have time to wait for the IT department of the company .

So, here is the trick to do it .

I have installed Java 1.7 version using the following procedure .

Use 7 zip to extract the installer , the exe file  .  After extracting the exe , I again extracted the core.zip file which was extracted in the previous step.

Now , I have the complete Java folder along with bin and lib folder .

Here comes the tricky part .

Now , if you do java -version , you will get error as below

Error occurred during initialization of VM
java/lang/NoClassDefFoundError: java/lang/Object

java -fullversion will work
java -fullversion
java full version "1.7.0_07-b11" 

Solution : Its taken from the link
http://stackoverflow.com/questions/11808829/jre-1-7-returns-java-lang-noclassdeffounderror-java-lang-object

Check in your JDK folder for *.pack files in jre/lib and jre/lib/ext such as rt.pack (the default location is Drive(C or D):\nameof_jdk_folder\jre\lib for Microsoft Windows and /usr/java/lib for Unix/GNU Linux)
Those *.pack files need to be unpacked to .jar files using this command:

For Windows:
%JAVA_HOME%\bin\unpack200 -r -v -l "" rt.pack rt.jar

For *nix, a similar command line will unpack the files:
cd /usr/java/lib
/usr/bin/unpack200 rt.pack rt.jar


Then run java -version .

You have successfully setup the Java .


Another way to do the Java setup is to copy the folder from an existing machine where the Java setup is already done. But for that , you need to have USB access to the machine which you may not be having .


In the above technique of installing Java , either you need to have the installable with you or You should have the internet access to download the JAVA installable.

No comments: