• Stars
    star
    2,778
  • Rank 16,396 (Top 0.4 %)
  • Language
    Go
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

(cross-platform) Java Version Manager

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/...)

export JABBA_VERSION=...
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:

export JABBA_VERSION=...
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:

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

In fish command looks a little bit different - export JABBA_VERSION=... 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.

More Repositories

1

mysql-binlog-connector-java

MySQL Binary Log connector
Java
2,212
star
2

kubesec

Secure Secret management for Kubernetes (with gpg, Google Cloud KMS and AWS KMS backends)
Go
608
star
3

commacd

A faster way to move around (Bash 3+/Zsh)
Shell
353
star
4

kubetpl

Kubernetes templates made easy #keep-it-simple #no-server-component
Go
209
star
5

skedule

A human-friendly alternative to cron. Designed after GAE's schedule for Kotlin and/or Java 8+.
Kotlin
84
star
6

gitlab-ci-build-on-merge-request

Missing "build on Merge Request" feature of Gitlab CI
Go
68
star
7

electron-har

A command-line tool for generating HTTP Archive (HAR) (based on Electron)
JavaScript
46
star
8

kubensx

Simpler Cluster/User/Namespace switching for Kubernetes (featuring interactive mode and wildcard/fuzzy matching)
Go
44
star
9

dotenv

A twelve-factor configuration (12factor.net/config) library for Java 8+
Java
42
star
10

docker-vm

A simple and transparent alternative to boot2docker (backed by Vagrant)
Shell
38
star
11

tsdm

No worries TypeScript definition manager
JavaScript
34
star
12

lorem

Filler text generator compatible with Node.js, Require.js and plain-old <script/>
JavaScript
33
star
13

bower-shrinkwrap-resolver

Missing shrinkwrap for Bower
JavaScript
33
star
14

dockry

Docker Registry V2 CLI (compatible with Docker Hub, GitLab Container Registry, etc; public or private)
Go
25
star
15

rook

Change Data Capture (CDC) toolkit for keeping system layers in sync with the database
Java
23
star
16

servers-maven-extension

Maven extension for exposing settings.xml/servers to ${}
Java
22
star
17

canvas-text-opentypejs-shim

Consistent text rendering for <canvas> (backed by opentype.js)
JavaScript
20
star
18

neutrino-preset-vue-static

A minimalistic starter kit for building static sites using Vue.js
JavaScript
16
star
19

levelkt

LevelDB client for Kotlin and/or Java 8+
Kotlin
14
star
20

dotfiles

Personal ~/*
Shell
13
star
21

k8sovpn

OpenVPN tunnel "to see the world the way pods see it" in Kubernetes
11
star
22

klob

A .gitgnore-pattern-based glob library for Kotlin and/or Java 8+
Kotlin
10
star
23

urxvt-clipboard-paste-on-right-click

rxvt-unicode extension that allows to paste the contents of your clipboard with the right click
Perl
10
star
24

bower-dependency-tree

Bower dependency tree visualizer
JavaScript
9
star
25

amqplib-auto-recovery

Automatic connection recovery for amqplib (squaremo/amqp.node)
JavaScript
9
star
26

vue-document

A 1kb document manager for Vue.js
JavaScript
6
star
27

hubot-starter-kit

Everything you need to get started with Hubot (Dockerfile included).
CoffeeScript
5
star
28

node-chrome-extension-id

A way to get Chromium / Google Chrome Extension ID
JavaScript
4
star
29

node-chrome-user-data-dir

An easy way to generate custom Chromium / Google Chrome profile (user data directory)
JavaScript
4
star
30

usage-maven-plugin

Maven Plugin for printing project Usage information
Java
3
star
31

jabba-autodiscovery

A simple mechanism for keeping jabba's index up-to-date
JavaScript
3
star
32

urxvt-selection-open

rxvt-unicode extension that allows to execute custom actions based on selection
Perl
2
star
33

node-finalize-addon

Object finalization based on N-API for Node.js v8.6.0+
C++
2
star
34

cucumber-js-caffeinator

Cucumber.js supercharged with Mocha reporters.
JavaScript
1
star
35

node-crx-parser

CRX parser
JavaScript
1
star
36

mappify

Dead-simple object mapping in Java
Java
1
star
37

native2asciiplug

Intellij IDEA native2ascii plugin
Java
1
star
38

hadoop-maven-plugin

Maven Plugin for Apache Hadoop
Java
1
star
39

checkstyle-nonstandard

Additional Checkstyle checks
Java
1
star
40

hubot-skype-over-phantomjs

Skype adapter for Hubot (the one that can be actually used on Raspberry Pi)
CoffeeScript
1
star
41

node-minimal-viable-pool

Minimal viable pool for Node.js
JavaScript
1
star
42

ijignore

.ijignore-controlled selective indexing for IntelliJ® Platform-based products (IDEA, WebStorm, ...).
Java
1
star
43

rcfg

Configurable package.json-aware sync/async .${app}rc loader
JavaScript
1
star