(cross-platform) Java Version Manager

Related tags

Utility jabba
Overview

jabba Latest Version Build Status

Java Version Manager inspired by nvm (Node.js). Written in Go.

The goal is to provide unified pain-free experience of installing (and switching between different versions of) JDK regardless of the OS (macOS, Linux x86/x86_64/ARMv7+, Windows x86_64).

jabba install

... and from custom URLs.

Installation

macOS / Linux

(in bash/zsh/...)

curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/jabba.sh

(use the same command to upgrade)

The script modifies common shell rc files by default. To skip these provide the --skip-rc flag to install.sh like so:

curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash -s -- --skip-rc && . ~/.jabba/jabba.sh

Make sure to source jabba.sh in your environment if you skip it:

[ -s "$JABBA_HOME/jabba.sh" ] && source "$JABBA_HOME/jabba.sh"

In fish command looks a little bit different - curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash; and . ~/.jabba/jabba.fish

If you don't have curl installed - replace curl -sL with wget -qO-.

If you are behind a proxy see - curl / wget manpage. Usually simple http_proxy=http://proxy-server:port https_proxy=http://proxy-server:port curl -sL ... is enough.

NOTE: The brew package is currently broken. We are working on a fix.

Docker

While you can use the same snippet as above, chances are you don't want jabba binary & shell integration script(s) to be included in the final Docker image, all you want is a JDK. Here is the Dockerfile showing how this can be done:

FROM buildpack-deps:jessie-curl

RUN curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | \
    JABBA_COMMAND="install 1.15.0 -o /jdk" bash

ENV JAVA_HOME /jdk
ENV PATH $JAVA_HOME/bin:$PATH

(when JABBA_COMMAND env variable is set install.sh downloads jabba binary, executes specified command and then deletes the binary)

$ docker build -t <image_name>:<image_tag> .
$ docker run -it --rm <image_name>:<image_tag> java -version

java version "1.15.0....

Windows 10

(in powershell)

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Expression (
  Invoke-WebRequest https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing
).Content

(use the same command to upgrade)

Usage

# list available JDK's
jabba ls-remote
# you can use any valid semver range to narrow down the list
jabba ls-remote zulu@~1.8.60
jabba ls-remote "*@>=1.6.45 <1.9" --latest=minor

# install Oracle JDK
jabba install 1.15.0
# install Oracle Server JRE
jabba install [email protected]  
# install Adopt OpenJDK (Hotspot)
jabba install [email protected]
# install Adopt OpenJDK (Eclipse OpenJ9)
jabba install [email protected]
# install Zulu OpenJDK
jabba install [email protected]
jabba install zulu@~1.8.144 # same as "zulu@>=1.8.144 <1.9" 
# install IBM SDK, Java Technology Edition
jabba install [email protected]
# install GraalVM CE
jabba install [email protected]
# install OpenJDK
jabba install [email protected]
# install OpenJDK with Shenandoah GC
jabba install [email protected]

# install from custom URL
# (supported qualifiers: zip (since 0.3.0), tgz, tgx (since 0.10.0), dmg, bin, exe)
jabba install 1.8.0-custom=tgz+http://example.com/distribution.tar.gz
jabba install 1.8.0-custom=tgx+http://example.com/distribution.tar.xz
jabba install 1.8.0-custom=zip+file:///opt/distribution.zip

# uninstall JDK
jabba uninstall [email protected]

# link system JDK
jabba link [email protected] /Library/Java/JavaVirtualMachines/jdk1.8.0_72.jdk

# list all installed JDK's
jabba ls

# switch to a different version of JDK (it must be already `install`ed)
jabba use [email protected]
jabba use zulu@~1.6.97

echo "1.8" > .jabbarc
# switch to the JDK specified in .jabbarc (since 0.5.0)
jabba use

# set default java version on shell (since 0.2.0)
# this version will automatically be "jabba use"d every time you open up a new terminal
jabba alias default 1.8

.jabbarc has to be a valid YAML file. JDK version can be specified as jdk: 1.8 or simply as 1.8 (same as ~1.8, 1.8.x ">=1.8.0 <1.9.0" (mind the quotes)).

jsyk: jabba keeps everything under ~/.jabba (on Linux/Mac OS X) / %USERPROFILE%/.jabba (on Windows). If at any point of time you decide to uninstall jabba - just remove this directory.

For more information see jabba --help.

Development

PREREQUISITE: go1.8

git clone https://github.com/shyiko/jabba $GOPATH/src/github.com/shyiko/jabba 
cd $GOPATH/src/github.com/shyiko/jabba 
make fetch

go run jabba.go

# to test a change
make test # or "test-coverage" if you want to get a coverage breakdown

# to make a build
make build # or "build-release" (latter is cross-compiling jabba to different OSs/ARCHs)   

FAQ

Q: What if I already have java installed?

A: It's fine. You can switch between system JDK and jabba-provided one whenever you feel like it (jabba use ... / jabba deactivate). They are not gonna conflict with each other.

Q: How do I switch java globally?

A: jabba doesn't have this functionality built-in because the exact way varies greatly between the operation systems and usually involves elevated permissions. But. Here are the snippets that should work:

  • Windows

(in powershell as administrator)

# select jdk
jabba use ...

# modify global PATH & JAVA_HOME
$envRegKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey('SYSTEM\CurrentControlSet\Control\Session Manager\Environment', $true)
$envPath=$envRegKey.GetValue('Path', $null, "DoNotExpandEnvironmentNames").replace('%JAVA_HOME%\bin;', '')
[Environment]::SetEnvironmentVariable('JAVA_HOME', "$(jabba which $(jabba current))", 'Machine')
[Environment]::SetEnvironmentVariable('PATH', "%JAVA_HOME%\bin;$envPath", 'Machine')
  • Linux

(tested on Debian/Ubuntu)

# select jdk
jabba use ...

sudo update-alternatives --install /usr/bin/java java ${JAVA_HOME%*/}/bin/java 20000
sudo update-alternatives --install /usr/bin/javac javac ${JAVA_HOME%*/}/bin/javac 20000

To switch between multiple GLOBAL alternatives use sudo update-alternatives --config java.

License

Apache License, Version 2.0

By using this software you agree to

This software is for educational purposes only.
Use it at your own risk.

Comments
  • Can't install zulu@1.9.0-3 on OS X 10.11.6

    Can't install [email protected] on OS X 10.11.6

    >  jabba install [email protected]
    Downloading [email protected] (http://cdn.azul.com/zulu-pre/bin/zulu9.0.0.3-ea-jdk9.0.0-macosx_x64.zip)
    107162597/107162597
    Extracting /var/folders/7p/lgzy74_52pzcszdwllr3whyw0000gn/T/jabba-d-764245852 to /Users/inanc/.jabba/jdk/[email protected]/Contents/Home
    -bash: exportommand not found
    -bash: 49: command not found
    -bash: 00m: command not found
    -bash: 49: command not found
    -bash: 00mPATHommand not found
    -bash: 49: command not found
    -bash: 00m=ommand not found
    -bash: 49: command not found
    -bash: 00m/Users/inanc/.jabba/jdk/[email protected]/Contents/Home/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/bin:/usr/local/sbin:/usr/local/redis/bin:/bin:/usr/bin:/usr/sbin:/sbin:./bin:/Users/inanc/bin:/Users/inanc/dev/bin:/Users/inanc/ImageMagick-6.8.8/bino such file or directory
    -bash: 49: command not found
    -bash: 00m: command not found
    -bash: 49: command not found
    -bash: 00m: command not found
    -bash: 49: command not found
    -bash: 00mJAVA_HOMEommand not found
    -bash: 49: command not found
    -bash: 00m=ommand not found
    -bash: 49: command not found
    -bash: 00m/Users/inanc/.jabba/jdk/[email protected]/Contents/Homeo such file or directory
    -bash: 49: command not found
    -bash: 00m: command not found
    -bash: 49: command not found
    -bash: 00m: command not found
    -bash: 49: command not found
    -bash: 00mJAVA_HOME_BEFORE_JABBAommand not found
    -bash: 49: command not found
    -bash: 00m=ommand not found
    -bash: 49: command not found
    -bash: 00mommand not found
    -bash: 49: command not found
    -bash: 00m: command not found
    
    opened by inancgumus 20
  • Bug?

    Bug?

    I get this when I try to install and run...any ideas? OSX 10.10.5

      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   259  100   259    0     0    733      0 --:--:-- --:--:-- --:--:--   733
    Installing v...
    
    Skipped update of /Users/myUser/.bashrc (source string already present)
    Skipped update of /Users/myUser/.bash_profile (source string already present)
    Skipped update of /Users/myUser/.profile (source string already present)
    Skipped update of /Users/myUser/.zshrc (source string already present)
    
    Installation completed
    (if you have any problems please report them at https://github.com/shyiko/jabba/issue)
    /Users/myUser/.jabba/bin/jabba: line 1: {error:Not Found}: command not found
    
    myUser~ $ jabba ls
    /Users/myUser/.jabba/bin/jabba: line 1: {error:Not Found}: command not found
    
    myUser~ $ cat /Users/myUser/.jabba/bin/jabba
    {"error":"Not Found"}
    
    opened by bliaxiong 14
  • Cannot install Java 7 on MacOSx

    Cannot install Java 7 on MacOSx

    MacOSx 10.12.5

    MacBook-Pro:~ aruizca$ jabba install 1.7
    Downloading 1.7.80 (http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-macosx-x64.dmg)
    7073/7073
    Mounting /var/folders/6z/tqx78p3d7x7ftzx_5h2jk8zm0000gn/T/jabba-d-056495298
    hdiutil: mount failed - image not recognized
    
    'hdiutil mount -mountpoint /var/folders/6z/tqx78p3d7x7ftzx_5h2jk8zm0000gn/T/jabba-i-540861753/jabba-d-056495298 /var/folders/6z/tqx78p3d7x7ftzx_5h2jk8zm0000gn/T/jabba-d-056495298' failed: exit status 1
    
    opened by aruizca 11
  • Jabba installed, not working.

    Jabba installed, not working.

    PS C:\Users\Kahaan Thakkar> jabba C:\Users\Kahaan : The term 'C:\Users\Kahaan' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

    • C:\Users\Kahaan Thakkar.jabba\bin\jabba.exe --fd3 C:\Users\Kahaan T ...
    •   + CategoryInfo          : ObjectNotFound: (C:\Users\Kahaan:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
      
      

    PS C:\Users\Kahaan Thakkar>

    opened by idk-pixel 7
  • GraalVM 20.2.0 support

    GraalVM 20.2.0 support

    I don't mind creating a PR for this, but from what I can tell it seems like there's an automatic sync process that adds the URLs to index.json? If so, it might not make sense for me to create a PR. Does the sync tool just need to be triggered on your side?

    opened by reibitto 6
  • Support graalvm java 8 and 11

    Support graalvm java 8 and 11

    #677 Since there is no support for graalvm java 8 especially for the current versions, I created graalvm8 and graalvm11 for each platform
    related issues #637 #572

    opened by 1Jo1 6
  • Add GraalVM AArch64 support for linux and Java 11

    Add GraalVM AArch64 support for linux and Java 11

    Looking here: https://github.com/graalvm/graalvm-ce-builds/releases, aarch64 architecture is supported for java 11 on linux. Can this be added to the list of supported jdks?

    What would be the process to add this? Just open a PR and add it manually? Looking at some open PRs it looked like there is some script running to sync jdks.

    opened by matsluni 5
  • adpot-versions not working

    adpot-versions not working

    Hi,

    I have several problems installing adopt and adopt-openj9. Also, aliases are not set property.

    adpot alias

    Given

    jabba ls-remote "adopt@"  --latest minor
    [email protected]
    [email protected]
    [email protected]
    

    When

    jabba install [email protected]

    Expected

    (Installation)

    Actual

    compatible version found for [email protected]

    adopt install

    Given

    jabba install [email protected]

    Expected

    (Install successfull)

    Actual outcome

    $ jabba install [email protected]
    Downloading [email protected] (https://github.com/AdoptOpenJDK/openjdk9-releases/releases/download/jdk-9%2B181/OpenJDK9_x64_Linux_jdk-9.181.tar.gz)                                                                                                                              
    129195/-1                                                                                                                                                                                                                                                                      
    Extracting /tmp/jabba-d-750752711 to $USER/.jabba/jdk/[email protected]                                                                                                                                                                                                  
    gzip: invalid header
    

    Same for adopt-openj9@*

    alias of adopt-openj9

    Given

    jabba ls-remote "adopt-openj9@"
    [email protected]
    [email protected]
    

    When

    jabba install [email protected]

    Expected

    (Install)

    Actual outcome

    No compatible version found for [email protected]
    Valid install targets:
    
    opened by bmarwell 5
  • PowerShell Alias

    PowerShell Alias

    So I have the following PowerShell Alias

    function SetJava-7 {
        Invoke-Expression "& `"C:\Users\{user_name}\.jabba\bin\jabba.exe`" use [email protected]"
    }
    
    function SetJava-8 {
        Invoke-Expression "& `"C:\Users\{user_name}\.jabba\bin\jabba.exe`" use [email protected]"
    }
    

    Set them like this :

    New-Alias sj7 SetJava-7
    
    New-Alias sj8 SetJava-8
    

    I run them and it's ok, it works, but the java version isn't changed, when I use the jabba command directly like bellow, it works, :

    jabba use [email protected]
    

    Can you guys give some help ?

    opened by FerreiraRaphael 5
  • Error with leiningen's detection of Java

    Error with leiningen's detection of Java

    Hi @shyiko

    I think that the way jabba currently works raises an error with leiningen.

    It works fine while I'm in the terminal but when I use the spacemacs and cider for clojure developement it's not able to detect the installed java at all.

    I've raised an issue here.

    https://github.com/syl20bnr/spacemacs/issues/9501

    opened by abhi18av 5
  • Add option to specify Jabba storage directory

    Add option to specify Jabba storage directory

    Hi! I was getting acquainted with Jabba and found that currently there is no way to set Jabba directory - it will always stay ~/.jabba. I think it would be cool to let user set it to anything else:

    • It would allow perfectionists to keep their home clean
    • It would allow system-global Jabba installs. System administrator may install Jabba as /usr/local/share/jabba with some default set of Java versions, and end users would have an option to keep a local Jabba installation if needed and switch from one to another.
    opened by etki 5
  • [Arch Linux] Keeps Trying to Extract Custom Java Versions to

    [Arch Linux] Keeps Trying to Extract Custom Java Versions to "/root/.jabba/"

    Jabba is successfully downloading custom versions of Java from the links I enter, but it keeps trying to extract to the corresponding directory inside "/root/.jabba/" when ".jabba" is located in "/home/[user]/." When it can't find "/root/.jabba/", it exits with the corresponding error.

    Exact terminal entries: [matt@MattsArchLaptop ~]$ sudo jabba install 1.8.0-custom=tgx+https://builds.shipilev.net/workspaces/aarch64-port-jdk8u-shenandoah.tar.xz Downloading 1.8.0-custom (https://builds.shipilev.net/workspaces/aarch64-port-jdk8u-shenandoah.tar.xz) 244464624/244464624 Extracting /tmp/jabba-d-1504402001 to /root/.jabba/jdk/1.8.0-custom /root/.jabba/jdk/1.8.0-custom/bin/java wasn't found. If you believe this is an error - please create a ticket at https://github.com/shyiko/jabba/issues (specify OS and command that was used)

    Linux Kernel: 5.15.81-1-lts Using Arch Linux x64 Arch Version: 2022.12.01 Using Jabba 0.11.2

    opened by luckyboy66666666 0
  • Windows installation unusable due to PowerShell issue

    Windows installation unusable due to PowerShell issue

    Just installed Jabba on Windows 10 Terminal (loggedin as admin)

    Here is what I get after I install Jabba:

    . : File C:\Users\GO\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded. The file C:\Users\GO\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3

    • . 'C:\Users\GO\Documents\WindowsPowerShell\Microsoft.PowerShell_profi ...
    • + CategoryInfo          : SecurityError: (:) [], PSSecurityException
      + FullyQualifiedErrorId : UnauthorizedAccess
      
      
      

    Trying to hack PowerShell with a temporary security bypass like Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass allows a temporary solution where jabba can get installed and used within the same session.

    And here is what I get when I open a new Terminal anywhere I need to use Java:

    jabba : The term 'jabba' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

    • jabba use [email protected]
    •   + CategoryInfo          : ObjectNotFound: (jabba:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException
      
      
    opened by gojforce 0
  • Use updated fork

    Use updated fork

    I recommend using the up to date community driven fork of this repo: https://github.com/Jabba-Team/jabba

    Or use https://get-coursier.io/ if you're using scala it has a jvm manager - https://alexarchambault.github.io/posts/2020-09-21-cs-setup.html#managed-jvm-directory

    opened by jaredmdobson 0
  • connection refused

    connection refused

    Command

    jabba ls-remote
    

    Response

    Get https://github.com/shyiko/jabba/raw/master/index.json: dial tcp: lookup github.com on [::1]:53: read udp [::1]:60967->[::1]:53: read: connection refused
    
    opened by experimentallife 0
  • Error: Could not find or load main class java

    Error: Could not find or load main class java

    NOTE: Vanilla Bedrock and TS3 may be buggy on aarch64 arhitecture Starting.... Found server.jar

    Java 17

    Installing v0.11.2... Skipped update of /home/container/.bashrc (source string already present) Skipped update of /home/container/.bash_profile (source string already present) Installation completed (if you have any problems please report them at https://github.com/shyiko/jabba/issues)

    openjdk version "17" 2021-09-14 OpenJDK Runtime Environment (build 17+35-2724) OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing) If you get error about java command not found then you need to set correct java version

    Error: Could not find or load main class java Caused by: java.lang.ClassNotFoundException: java

    opened by AlipBot 0
Releases(0.11.2)
Owner
Stanley Shyiko
Stanley Shyiko
Jyxal - a coffee-flavored version of Vyxal compiled for the Java Virtual Machine

Jyxal is a coffee-flavored version of Vyxal compiled for the Java Virtual Machine. A list of differences can be seen here. Running Note: Jyxal a

null 10 May 19, 2022
The shell for the Java Platform

______ .~ ~. |`````````, .'. ..'''' | | | |'''|''''' .''```. .'' |_________| |

CRaSH Repositories 916 Dec 30, 2022
Gephi - The Open Graph Viz Platform

Gephi - The Open Graph Viz Platform Gephi is an award-winning open-source platform for visualizing and manipulating large graphs. It runs on Windows,

Gephi 5.1k Dec 30, 2022
Java lib for monitoring directories or individual files via java.nio.file.WatchService

ch.vorburger.fswatch Java lib for monitoring directories or individual files based on the java.nio.file.WatchService. Usage Get it from Maven Central

Michael Vorburger ⛑️ 21 Jan 7, 2022
Tencent Kona JDK11 is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-Term Support(LTS) with quarterly updates. Tencent Kona JDK11 is certified as compatible with the Java SE standard.

Tencent Kona JDK11 Tencent Kona JDK11 is a no-cost, production-ready distribution of the Open Java Development Kit (OpenJDK), Long-Term Support(LTS) w

Tencent 268 Dec 16, 2022
This repository contains Java programs to become zero to hero in Java.

This repository contains Java programs to become zero to hero in Java. Data Structure programs topic wise are also present to learn data structure problem solving in Java. Programs related to each and every concep are present from easy to intermidiate level

Sahil Batra 15 Oct 9, 2022
An open-source Java library for Constraint Programming

Documentation, Support and Issues Contributing Download and installation Choco-solver is an open-source Java library for Constraint Programming. Curre

null 607 Jan 3, 2023
Java Constraint Programming solver

https://maven-badges.herokuapp.com/maven-central/org.jacop/jacop/badge.svg [] (https://maven-badges.herokuapp.com/maven-central/org.jacop/jacop/) JaCo

null 202 Dec 30, 2022
Java Constraint Solver to solve vehicle routing, employee rostering, task assignment, conference scheduling and other planning problems.

OptaPlanner www.optaplanner.org Looking for Quickstarts? OptaPlanner’s quickstarts have moved to optaplanner-quickstarts repository. Quick development

KIE (Drools, OptaPlanner and jBPM) 2.8k Jan 2, 2023
Alibaba Java Diagnostic Tool Arthas/Alibaba Java诊断利器Arthas

Arthas Arthas is a Java Diagnostic tool open sourced by Alibaba. Arthas allows developers to troubleshoot production issues for Java applications with

Alibaba 31.5k Jan 4, 2023
Java rate limiting library based on token/leaky-bucket algorithm.

Java rate-limiting library based on token-bucket algorithm. Advantages of Bucket4j Implemented on top of ideas of well known algorithm, which are by d

Vladimir Bukhtoyarov 1.7k Jan 8, 2023
Object-Oriented Java primitives, as an alternative to Google Guava and Apache Commons

Project architect: @victornoel ATTENTION: We're still in a very early alpha version, the API may and will change frequently. Please, use it at your ow

Yegor Bugayenko 691 Dec 27, 2022
Dex : The Data Explorer -- A data visualization tool written in Java/Groovy/JavaFX capable of powerful ETL and publishing web visualizations.

Dex Dex : The data explorer is a powerful tool for data science. It is written in Groovy and Java on top of JavaFX and offers the ability to: Read in

Patrick Martin 1.3k Jan 8, 2023
Google core libraries for Java

Guava: Google Core Libraries for Java Guava is a set of core Java libraries from Google that includes new collection types (such as multimap and multi

Google 46.5k Jan 1, 2023
Java regular expressions made easy.

JavaVerbalExpressions VerbalExpressions is a Java library that helps to construct difficult regular expressions. Getting Started Maven Dependency: <de

null 2.6k Dec 30, 2022
MinIO Client SDK for Java

MinIO Java SDK for Amazon S3 Compatible Cloud Storage MinIO Java SDK is Simple Storage Service (aka S3) client to perform bucket and object operations

High Performance, Kubernetes Native Object Storage 787 Jan 3, 2023
java port of Underscore.js

underscore-java Requirements Java 1.8 and later or Java 11. Installation Include the following in your pom.xml for Maven: <dependencies> <dependency

Valentyn Kolesnikov 411 Dec 6, 2022
Manage your Java environment

Master your Java Environment with jenv Website : http://www.jenv.be Maintainers : Gildas Cuisinier Future maintainer in discussion: Benjamin Berman As

jEnv 4.6k Dec 30, 2022
Hashids algorithm v1.0.0 implementation in Java

Hashids.java A small Java class to generate YouTube-like hashes from one or many numbers. Ported from javascript hashids.js by Ivan Akimov What is it?

CELLA 944 Jan 5, 2023