为了账号安全,请及时绑定邮箱和手机立即绑定

sdkman安装java开发环境

2018.09.08 21:31 4885浏览

sdkman管理Java软件多版本切换

sdkman(Software Development Kit Manager,简称SDKMAN)是用来方便的管理多个版本的开发环境的工具,提供简洁的命令列出支持的软件如:java maven spring scala等等,支持的软件还在逐步增加。sdkman支持安装在任意的UNIX Based系统平台 如:Mac OSX, Linux, Cygwin, Solaris, FreeBSD

为什么使用sdkman?sdkman大大简化了我们配置java环境,原来的下载jdk、安装、配置环境变量等等繁琐重复操作由一个命令代替,并且可以方便切换java的版本,除了java外sdkman还支持十几种与java相关的软件如maven,spring,scala等等……

sdkman唯一的不便之处就是网站频繁被墙,当然这不怪sdkman,学会翻墙是学习技术的第一道门槛
在实战课程里面有视频演示安装,感兴趣的同学可以查看Activiti6.0工作流引擎深度解析与实战

安装sdkman

curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk version

查看支持的软件

sdk list
================================================================================
Available Candidates
================================================================================
q-quit                                  /-search down
j-down                                  ?-search up
k-up                                    h-help

--------------------------------------------------------------------------------
Ant (1.10.1)                                             https://ant.apache.org/

Apache Ant is a Java library and command-line tool whose mission is to drive
processes described in build files as targets and extension points dependent
upon each other. The main known usage of Ant is the build of Java applications.
Ant supplies a number of built-in tasks allowing to compile, assemble, test and
run Java applications. Ant can also be used effectively to build non Java
applications, for instance C or C++ applications. More generally, Ant can be
used to pilot any type of process which can be described in terms of targets and
tasks.

                                                               $ sdk install ant
--------------------------------------------------------------------------------
AsciidoctorJ (1.5.7)                                     http://asciidoctor.org/

AsciidoctorJ is the official library for running Asciidoctor on the JVM. Using

================================================================================
Available Candidates
================================================================================
q-quit                                  /-search down
j-down                                  ?-search up
k-up                                    h-help

--------------------------------------------------------------------------------
Ant (1.10.1)                                             https://ant.apache.org/

Apache Ant is a Java library and command-line tool whose mission is to drive
processes described in build files as targets and extension points dependent
upon each other. The main known usage of Ant is the build of Java applications.
Ant supplies a number of built-in tasks allowing to compile, assemble, test and
run Java applications. Ant can also be used effectively to build non Java
applications, for instance C or C++ applications. More generally, Ant can be
used to pilot any type of process which can be described in terms of targets and
tasks.

                                                               $ sdk install ant
--------------------------------------------------------------------------------
AsciidoctorJ (1.5.7)                                     http://asciidoctor.org/

AsciidoctorJ is the official library for running Asciidoctor on the JVM. Using
AsciidoctorJ, you can convert AsciiDoc content or analyze the structure of a
parsed AsciiDoc document from Java and other JVM languages.

                                                      $ sdk install asciidoctorj
--------------------------------------------------------------------------------
Bpipe (0.9.9.6)                                                 http://bpipe.org

Bpipe is a framework for running computational pipelines and workflows

                                                             $ sdk install bpipe
--------------------------------------------------------------------------------
Ceylon (1.3.3)                                           http://ceylon-lang.org/

Ceylon is a modern, modular, statically typed programming language for the Java
and JavaScript virtual machines. The language features a flexible and very
readable syntax, a unique and uncommonly elegant static type system, a powerful
module architecture, and excellent tooling.

                                                            $ sdk install ceylon
--------------------------------------------------------------------------------
CRaSH (1.3.0)                                            http://www.crashub.org/

The Common Reusable SHell (CRaSH) deploys in a Java runtime and provides
interactions with the JVM. Commands are written in Groovy or Java and can be
developed at runtime making the extension of the shell very easy with fast
development cycle.

                                                             $ sdk install crash
--------------------------------------------------------------------------------
CUBA CLI (1.0.1)                                       https://cuba-platform.com

CUBA CLI is an open source command line utility that enables you to easily
create projects based on CUBA Platform

                                                              $ sdk install cuba
--------------------------------------------------------------------------------
CXF (3.2.5)                                              https://cxf.apache.org/

     1.0.0-rc5-graal

================================================================================
Available Candidates
================================================================================
q-quit                                  /-search down
j-down                                  ?-search up
k-up                                    h-help

--------------------------------------------------------------------------------
Ant (1.10.1)                                             https://ant.apache.org/

Apache Ant is a Java library and command-line tool whose mission is to drive
processes described in build files as targets and extension points dependent
upon each other. The main known usage of Ant is the build of Java applications.
Ant supplies a number of built-in tasks allowing to compile, assemble, test and
run Java applications. Ant can also be used effectively to build non Java
applications, for instance C or C++ applications. More generally, Ant can be
used to pilot any type of process which can be described in terms of targets and
tasks.

                                                               $ sdk install ant
--------------------------------------------------------------------------------
AsciidoctorJ (1.5.7)                                     http://asciidoctor.org/

AsciidoctorJ is the official library for running Asciidoctor on the JVM. Using
AsciidoctorJ, you can convert AsciiDoc content or analyze the structure of a
parsed AsciiDoc document from Java and other JVM languages.

                                                      $ sdk install asciidoctorj
--------------------------------------------------------------------------------
Bpipe (0.9.9.6)                                                 http://bpipe.org

Bpipe is a framework for running computational pipelines and workflows

                                                             $ sdk install bpipe
--------------------------------------------------------------------------------
Ceylon (1.3.3)                                           http://ceylon-lang.org/

Ceylon is a modern, modular, statically typed programming language for the Java
and JavaScript virtual machines. The language features a flexible and very
readable syntax, a unique and uncommonly elegant static type system, a powerful
module architecture, and excellent tooling.

                                                            $ sdk install ceylon
--------------------------------------------------------------------------------
CRaSH (1.3.0)                                            http://www.crashub.org/

The Common Reusable SHell (CRaSH) deploys in a Java runtime and provides
interactions with the JVM. Commands are written in Groovy or Java and can be
developed at runtime making the extension of the shell very easy with fast
development cycle.

                                                             $ sdk install crash
--------------------------------------------------------------------------------
CUBA CLI (1.0.1)                                       https://cuba-platform.com

CUBA CLI is an open source command line utility that enables you to easily
create projects based on CUBA Platform

                                                              $ sdk install cuba
--------------------------------------------------------------------------------
CXF (3.2.5)                                              https://cxf.apache.org/

Apache CXF is an open source services framework. CXF helps you build and develop
services using frontend programming APIs, like JAX-WS and JAX-RS. These services
can speak a variety of protocols such as SOAP, XML/HTTP, RESTful HTTP, or CORBA
and work over a variety of transports such as HTTP, JMS or JBI.

                                                               $ sdk install cxf
--------------------------------------------------------------------------------
Gaiden (1.1)                                       http://kobo.github.io/gaiden/

Gaiden is a tool that makes it easy to create documentation with Markdown.

                                                            $ sdk install gaiden
--------------------------------------------------------------------------------
Glide (0.9.2)                                      http://glide-gae.appspot.com/

Glide makes it incredibly easy to develop apps that harness the power of Google
App Engine for Java using expressiveness of Groovy and sweetness of Gaelyk s
syntactic sugar.

                                                             $ sdk install glide
--------------------------------------------------------------------------------
Gradle (4.10)                                                 http://gradle.org/

Gradle is a build automation tool that builds upon the concepts of Apache Ant
and Apache Maven and introduces a Groovy-based domain-specific language (DSL)
instead of the more traditional XML form of declaring the project configuration.
Gradle uses a directed acyclic graph (DAG) to determine the order in which tasks
can be run.

                                                            $ sdk install gradle
--------------------------------------------------------------------------------
Grails (3.3.8)                                               https://grails.org/

Grails is a powerful web framework, for the Java platform aimed at multiplying
developers productivity thanks to a Convention-over-Configuration, sensible
defaults and opinionated APIs. It integrates smoothly with the JVM, allowing you
to be immediately productive whilst providing powerful features, including
integrated ORM, Domain-Specific Languages, runtime and compile-time
meta-programming and Asynchronous programming.

                                                            $ sdk install grails
--------------------------------------------------------------------------------
Groovy (2.5.2)                                       http://www.groovy-lang.org/

Groovy is a powerful, optionally typed and dynamic language, with static-typing
and static compilation capabilities, for the Java platform aimed at multiplying
developers' productivity thanks to a concise, familiar and easy to learn syntax.
It integrates smoothly with any Java program, and immediately delivers to your
application powerful features, including scripting capabilities, Domain-Specific
Language authoring, runtime and compile-time meta-programming and functional
programming.

                                                            $ sdk install groovy
--------------------------------------------------------------------------------
GroovyServ (1.2.0)                            https://kobo.github.io/groovyserv/

GroovyServ reduces startup time of the JVM for runnning Groovy significantly. It
depends on your environments, but in most cases, it’s 10 to 20 times faster than
regular Groovy.

                                                        $ sdk install groovyserv
--------------------------------------------------------------------------------
Infrastructor (0.2.1)                                   http://infrastructor.io/

Infrastructor is an open source server provisioning tool written in Groovy

                                                     $ sdk install infrastructor
--------------------------------------------------------------------------------
Java (8.0.181-zulu)                                            https://zulu.org/

Java Platform, Standard Edition (or Java SE) is a widely used platform for
development and deployment of portable code for desktop and server environments.
Java SE uses the object-oriented Java programming language. It is part of the
Java software-platform family. Java SE defines a wide range of general-purpose
APIs – such as Java APIs for the Java Class Library – and also includes the Java
Language Specification and the Java Virtual Machine Specification.

                                                              $ sdk install java
--------------------------------------------------------------------------------
JBake (2.6.1)                                                  http://jbake.org/

JBake is a Java based, open source, static site/blog generator for developers
and designers.

                                                             $ sdk install jbake
--------------------------------------------------------------------------------
Kotlin (1.2.61)                                          https://kotlinlang.org/

Kotlin is a statically-typed programming language that runs on the Java Virtual
Machine and can also be compiled to JavaScript source code.

                                                            $ sdk install kotlin
--------------------------------------------------------------------------------
kscript (2.4.5)                          https://github.com/holgerbrandl/kscript

Enhanced scripting support for Kotlin on *nix-based systems. kscript provides an
easy-to-use, very flexible, and almost zero-overhead solution to write
self-contained mini-applications with Kotlin.

                                                           $ sdk install kscript
--------------------------------------------------------------------------------
Lazybones (0.8.3)                        https://github.com/pledbrook/lazybones/

Lazybones allows you to create a new project structure for any framework or
library for which the tool has a template.

                                                         $ sdk install lazybones
--------------------------------------------------------------------------------
Leiningen (2.7.1)                                          http://leiningen.org/

Leiningen is the easiest way to use Clojure. With a focus on project automation
and declarative configuration, it gets out of your way and lets you focus on
your code.

                                                         $ sdk install leiningen
--------------------------------------------------------------------------------
Maven (3.5.4)                                          https://maven.apache.org/

Apache Maven is a software project management and comprehension tool. Based on
the concept of a project object model (POM), Maven can manage a project's build,
reporting and documentation from a central piece of information.

                                                             $ sdk install maven
--------------------------------------------------------------------------------
Micronaut (1.0.0.M4)                                        http://micronaut.io/

Micronaut is an open source microservice framework for the JVM

                                                         $ sdk install micronaut
--------------------------------------------------------------------------------
sbt (1.2.1)                                            http://www.scala-sbt.org/

SBT is an open source build tool for Scala and Java projects, similar to Java's
Maven or Ant. Its main features are: native support for compiling Scala code and
integrating with many Scala test frameworks; build descriptions written in Scala
using a DSL; dependency management using Ivy (which supports Maven-format
repositories); continuous compilation, testing, and deployment; integration with
the Scala interpreter for rapid iteration and debugging; support for mixed
Java/Scala projects

                                                               $ sdk install sbt
--------------------------------------------------------------------------------
Scala (2.12.6)                                        http://www.scala-lang.org/

Scala is a programming language for general software applications. Scala has
full support for functional programming and a very strong static type system.
This allows programs written in Scala to be very concise and thus smaller in
size than other general-purpose programming languages. Scala source code is
intended to be compiled to Java bytecode, so that the resulting executable code
runs on a Java virtual machine. Java libraries may be used directly in Scala
code and vice versa. Scala is object-oriented, and uses a curly-brace syntax.
Scala has many features of functional programming languages, including currying,
type inference, immutability, lazy evaluation, and pattern matching. It also has
an advanced type system supporting algebraic data types, covariance and
contravariance, higher-order types, and anonymous types. Other features of Scala
include operator overloading, optional parameters, named parameters, raw
strings, and no checked exceptions.

                                                             $ sdk install scala
--------------------------------------------------------------------------------
Spark (2.3.1)                                          https://spark.apache.org/

Apache Spark is an open-source cluster-computing framework. Spark provides an
interface for programming entire clusters with implicit data parallelism and
fault-tolerance.

                                                             $ sdk install spark
--------------------------------------------------------------------------------
Spring Boot (2.0.4.RELEASE)               http://projects.spring.io/spring-boot/

Spring Boot takes an opinionated view of building production-ready Spring
applications. It favors convention over configuration and is designed to get you
up and running as quickly as possible.

                                                        $ sdk install springboot
--------------------------------------------------------------------------------
Sshoogr (0.9.25)                             https://github.com/aestasit/sshoogr

Sshoogr is a Groovy based DSL and command line tool for working with remote
servers through SSH.

                                                           $ sdk install sshoogr
--------------------------------------------------------------------------------
Vert.x (3.5.3)                                                  http://vertx.io/

Vert.x is a tool-kit for building reactive applications on the JVM.

                                                             $ sdk install vertx
--------------------------------------------------------------------------------
VisualVM (1.4.1)                                     https://visualvm.github.io/

VisualVM is a tool that provides a visual interface for viewing detailed
information about Java applications while they are running on a Java Virtual
Machine.

                                                          $ sdk install visualvm
--------------------------------------------------------------------------------

可以看到跟java相关的各种工具

基于sdkman安装java

我们列出sdkman支持的各种java版本,注意sdkman并不是支持所有的版本,最常用的java7,8,9都是支持的

 ~  sdk ls java
================================================================================
Available Java Versions
================================================================================
     12.ea.08-open
     11.ea.28-open
     10.0.2-zulu
     10.0.2-open
     10.0.2-oracle
     9.0.7-zulu
     9.0.4-open
   + 8u161-oracle
   + 8u152-zulu
   + 8u131-zulu
 > * 8.0.181-zulu
     8.0.181-oracle
   + 7u141-zulu
     7.0.181-zulu
     1.0.0-rc5-graal

================================================================================
+ - local version
* - installed
> - currently in use
================================================================================

安装指定的版本,如果不选择版本默认安装最新的版本

 ~  sdk install java 9.0.4-open
Downloading: java 9.0.4-open

In progress...

##                                                                         3.5%

临时使用java指定的版本 当前shell有效

~ sdk use java 8u161-oracle

Using java version 8u161-oracle in this shell.

切换java到指定版本 全局生效

~ sdk default java 8u161-oracle

Default java version set to 8u161-oracle

安装maven

安装maven最新版本,并设置为默认版本

~ sdk install maven

其它java相关软件一样如springboot

~ sdk install springboot

查看sdk安装的软件

 ~ sdk current
Using:

gradle: 4.10
groovy: 2.5.2
java: 8u161-oracle
jbake: 2.6.1
maven: 3.5.4
scala: 2.12.6
spark: 2.3.1
springboot: 2.0.4.RELEASE
visualvm: 1.4.1

后记

几个命令轻松安装java开发环境确实挺方便,java攻城狮再也不怕重装系统了
传送门 https://sdkman.io/ ps:网站经常不定期被墙

点击查看更多内容

本文原创发布于慕课网 ,转载请注明出处,谢谢合作

5人点赞

若觉得本文不错,就分享一下吧!

评论

相关文章推荐

正在加载中
意见反馈 邀请有奖 帮助中心 APP下载
官方微信

举报

0/150
提交
取消