'Portable Java Installation

I'm trying to make Java work with some commands in a .bat file without installation. I have the Java folder that is installed in C:\Program Files when you normally install Java and Init.bat which does this:

set JAVA_HOME="C:\Users\mega\Desktop\DISK\Apps\Java"
set PATH=%PATH%;C:\Users\mega\Desktop\DISK\Apps\Java\bin
assoc .jar=jarfile
ftype jarfile="C:\Users\mega\Desktop\DISK\Apps\Java\bin\javaw.exe" "%1"

It should set the 2 environment variables and associating the variables, first of all, they don't set the variables, I do not know why but I am sure that I can fix it after this topic, but even then, I set them manually and when I try to open a .jar file it doesn't work.

So the Java is in 1 folder and it should function like if a Java were to be installed normally, but it doesn't, any help is good since I can't figure it out.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source