Skip to content

Switches between java and maven versions for cmd/bash/zsh sessions.

License

Notifications You must be signed in to change notification settings

cccaaannn/java-version-switcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Version Switcher


Switches between java and maven versions for cmd/bash/zsh sessions.

GitHub license GitHub top language

Script setup

  1. In addition to regular JAVA_HOME environment variable, different java versions has to be set as environment variables in order to script to work. See Environment example.
  2. Environment variable naming should follow this convention JAVA_HOME_<VERSION>.
    • Ex: JAVA_HOME_18
  3. Using same naming convention, more M2_HOME variables can also be set for maven version switching M2_HOME_<VERSION>.
    • Ex: M2_HOME_3.6
  • For linux, script has to be run with source for new environment variables to be active on the session, you can create an alias for it alias jvs="source jvs.sh"

Commands

  • -h, --help Prints help message.
  • -a, --about Shows about jvs.
  • -m <MAVEN_VERSION>, --maven <MAVEN_VERSION> Used for switching maven version.

Usage

  • jvs <JAVA_VERSION>
  • jvs <JAVA_VERSION> -m <MAVEN_VERSION>

Examples

  • jvs 11
  • jvs 1.8 -m 3.6
  • jvs 18 --maven 3.8

 

Environment example

  1. Windows

    drawing
  2. Linux

    export JAVA_HOME=/home/<user>/.jdks/openjdk-23
    export JAVA_HOME_23=/home/<user>/.jdks/openjdk-23
    export JAVA_HOME_22=/home/<user>/.jdks/temurin-22.0.1
    export M2_HOME=/home/<user>/maven/apache-maven-3.9.8
    export M2_HOME_39=/home/<user>/maven/apache-maven-3.9.8
    export M2_HOME_36=/home/<user>/maven/apache-maven-3.6.0
    

About

Switches between java and maven versions for cmd/bash/zsh sessions.

Topics

Resources

License

Stars

Watchers

Forks