8000 GitHub - rcoy-v/jabba: Install and manage Java with ease
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

rcoy-v/jabba

 
 

Repository files navigation

jabba Latest Version Build Status

jabba-the-hutt

Java Version Manager inspired by nvm (Node.js). You might have come across similar beauty in Go (gvm) or Ruby (rvm).

Supports installation of Oracle JDK (default), Zulu OpenJDK (since 0.3.0) and from custom URLs.

It's written in Go to make maintenance easier (significantly shorter, easier to understand and less prone to errors compared to pure shell implementation). Plus it enables us to support Windows natively (no need for Cygwin) without rewriting the whole thing in PowerShell or whatever.

The goal is to provide unified pain-free experience of installing (and switching between different versions of) JDK regardless of the OS.

jabba has a single responsibility - managing different versions of JDK. For an easy way to install Scala/Kotlin/Groovy (+ a lot more) see SDKMAN. SBT/Maven/Gradle should ideally be "fixed in place" by sbt-launcher/mvnw/gradlew.

Installation

(use the same command to upgrade)

  • Linux/Mac OS X

(in bash/zsh/...)

curl -sL https://github.com/shyiko/jabba/raw/master/install.sh | bash && . ~/.jabba/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.

  • Windows 10

(in powershell)

Invoke-Expression (wget https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing).Content

Usage

# install Oracle JDK
jabba install 1.8 # "jabba use 1.8" will be called automatically  

# install Zulu OpenJDK (since 0.3.0)
jabba install zulu@1.8.72

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

# list all installed JDK's
jabba ls

# switch to a different version of JDK
jabba use 1.6.65

# list available JDK's
jabba ls-remote

# 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.6.65

jsyk: jabba keeps everything under ~/.jabba (on Linux/Mac OS X) / %USERPROFILE%/.jabba (on Windows).

For more information see jabba --help.

Development

PREREQUISITE: go1.6

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;', '')
setx JAVA_HOME "$(jabba which $(jabba current))" /m
setx PATH "%JAVA_HOME%\bin;$envPath" /m

License

Apache License, Version 2.0

By using this software you agree to Oracle Binary Code License Agreement for the Java SE Platform Products and JavaFX and Oracle Technology Network Early Adopter Development License Agreement (in case of EA releases) (... and Apple's Software License Agreement in case of "Java for OS X").

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

About

Install and manage Java with ease

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 81.1%
  • Shell 10.2%
  • PowerShell 5.4%
  • Makefile 3.3%
0