Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

batch file to switch between java version

@echo off
echo.

IF "%1" == ""       GOTO NoParams
IF "%1" == "8"      GOTO J8
IF "%1" == "11"     GOTO J11
IF "%1" == "latest" GOTO latest

IF "%1" == "-h"         GOTO help
IF "%1" == "--help"     GOTO help

:NoParams
    echo Enter Java version
    GOTO options
    
:help
    echo Usage: javaVer [java version]
    GOTO options

:: available java versions
:options
    echo options: 8, 11, latest.
    GOTO exit

:: java 8
:J8
    set JAVA_HOME=C:Program FilesJavajdk8u282-b08
    GOTO activate

:: java 11
:J11
    set JAVA_HOME=C:Program FilesJavajdk-11.0.10+9
    GOTO activate

:: latest java version
:latest
    set JAVA_HOME=C:Program FilesJavajdk-15.0.2+7
    GOTO activate

:: activates the selected java version
:activate
    set Path=%JAVA_HOME%in;%Path%
    echo Java %1 activated.
    GOTO exit

:: prints java version
:exit
    echo.
    echo Current Java version:
    java -version
Comment

PREVIOUS NEXT
Code Example
Java :: access modifier overloaded method 
Java :: MinimumAndMaximum 
Java :: java.lang.IllegalMonitorStateException: object not locked by thread before wait() 
Java :: Dhttps.protocols=TLSv1.2 
Java :: struct in java 
Java :: candies price hackerearth solution in java 
Java :: java hashset api 
Java :: Java Enable assertion in class names 
Java :: Java Protected Access Modifier package one 
Java :: java class creation inside method 
Java :: java format zero padded binary 
Java :: spring component 
Java :: java classes and objects 
Java :: java function 
Java :: java to kotlin tutorial 
Java :: || in java 
Java :: java enum from int 
Java :: extract html tag using regex 
Java :: lombok 
Java :: java float 
Java :: Leap year or not program in java using if-else 
Java :: my animal list 
Java :: declare variable java 
Sql :: mysql show users 
Sql :: mysql list bigger table 
Sql :: freemysqlhosting keeps deleting tables 
Sql :: mysql force query to use index 
Sql :: postgresql list extensions 
Sql :: how to remove tables from postgresql 
Sql :: set mysql mode global query 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =