Reputation: 256
I have installed both a jdk and android studio on a usb drive, however android studio doesn't seem to want to launch from that jdk (it instead says none are installed), I have looked online and these solutions have been suggested: - Adding the JDK to my system path file, as I want to run this on a school computer that wont be possible, as you need admin - Changing the settings inside of android studio, given that i cant even get it to launch this is not an option - I have tried to add something to the studio.bat, but I probably got it wrong, and it didn't work.
I think the most promising option is to add it to studio.bat, would any of you know how to do this (the jdk is located in the same drive but in/jdk no/AndroidStudio)?
I would be open to other options that don't require admin permission.
I have poked around and I think this would be a solution but i can't work out how:
I need to add E:\JDK7 as my JAVA_HOME to this file (studio.bat):
IF EXIST "%ANDROID_STUDIO_JDK%" SET JDK=%ANDROID_STUDIO_JDK%
IF NOT "%JDK%" == "" GOTO jdk
IF EXIST "%~dp0\..\jre" SET JDK=%~dp0\..\jre
IF NOT "%JDK%" == "" GOTO jdk
IF EXIST "%JDK_HOME%" SET JDK=%JDK_HOME%
IF NOT "%JDK%" == "" GOTO jdk
IF EXIST "%JAVA_HOME%" SET JDK=%JAVA_HOME%
IF "%JDK%" == "" GOTO error
:jdk
SET JAVA_EXE=%JDK%\bin\java.exe
IF NOT EXIST "%JAVA_EXE%" SET JAVA_EXE=%JDK%\jre\bin\java.exe
IF NOT EXIST "%JAVA_EXE%" GOTO error
SET JRE=%JDK%
IF EXIST "%JRE%\jre" SET JRE=%JDK%\jre
SET BITS=
IF EXIST "%JRE%\lib\amd64" SET BITS=64
I have tried adding this to the file (below IF EXIST "%JAVA_HOME):
IF NOT "%JDK%" == "" GOTO jdk
IF EXIST "E:\JDK7" SET JDK=E:\JDK7
Upvotes: 1
Views: 8921
Reputation: 37
1) Extract tools.zip from downloaded JDK, then run
for /R %f in (.\*.pack) do @"/path/to/tools.zip/bin/unpack200" -r -v -l "" "%f" "%~pf%~nf.jar"
2) Move the extracted folder under Android Studio, then rename it to "jre".
3) Profit.
FYI how the folder tree likes:
~/AndroidStudio/ bin/ lib/ ... jre/
Upvotes: 0
Reputation: 36
Batch file work for me. I have jdk installed on a usb stick at the location \Java\jdk1.7.0_75 and a studio.bat file with:
set Path=\Java\jdk1.7.0_75\bin;%Path%
set JDK_HOME=%JDK%\java\jdk1.7.0_75
set JAVA_HOME=%JAVA%\java\jdk1.7.0_75
\AndroidStudio\bin\studio
Upvotes: 2