To be able to call the scripts from anywhere, you have to add the directory to the "Path" environment variable (just like you did with "%JAVA_HOME%\bin" in the second step): This only affects the currently opened command line.) Step 4: Add the Script Directory to the Path (The Path variable gets longer with each change. That makes it the first directory to be searched for the corresponding executable when you run Java commands such as java or javac. The scripts update the JAVA_HOME environment variable and insert the bin directory at the beginning of the Path variable. In the files javaX.bat and javaX.ps1, you probably have to adjust some paths to the installed Java versions. $env:Path = $env:JAVA_HOME '\bin ' $env:Path Write-Output " $javaVersion activated." Code language: PowerShell ( powershell ) ::SetEnvironmentVariable( "JAVA_HOME", $env:JAVA_HOME, ::Machine) Set Path= %JAVA_HOME%\bin %Path% echo %~ 1 activated. If % 1 = "Java 20" set JAVA_HOME=C:\Program Files\Java\jdk- 20 if % 1 = "Java 21" set JAVA_HOME=C:\Program Files\Java\jdk- 21 if "%~ 2" = "perm" ( 3" set JAVA_HOME=C:\Program Files (x86)\Java\jdk1. 2" set JAVA_HOME=C:\Program Files (x86)\Java\jdk1. I suggest you unpack the scripts to C:\Program Files\Java\scripts.Ĭall javaX "Java 20" % 1 Code language: DOS.
0 Comments
Leave a Reply. |