LoginSignup
1
1

More than 5 years have passed since last update.

GroovyをRaspberry Piにインストールする

Last updated at Posted at 2015-11-03

概要

SDKMANを使ってGroovyを入れる。
インストール先はRaspberry Pi上のLinux(Debian)。
LinuxとMacはほぼ同じ手順使えるはず。

前提

JDKがインストール済みであること。
インターネットに繋がっていること。

SDKMANをインストールする

インストール

curl -s http://get.sdkman.io | bash

こんなログが出ればOK

output
(前略)
All done!
Please open a new terminal, or run the following in the existing one:
    source "/home/pi/.sdkman/bin/sdkman-init.sh"
Then issue the following command:
    sdk help
Enjoy!!!

環境変数の設定(たぶん)

source "/home/pi/.sdkman/bin/sdkman-init.sh"

確認

sdk help

Usageが出ればOK。

Groovyインストール

インストールできるバージョンを確認する

sdk list groovy
output
=====================================================================
Available Groovy Versions
=====================================================================
     2.4.5     2.3.10    2.1.0     1.8.4
     2.4.4     2.3.1     2.0.8     1.8.3
     2.4.3     2.3.0     2.0.7     1.8.2
     2.4.2     2.2.2     2.0.6     1.8.1
     2.4.1     2.2.1     2.0.5     1.8.0
     2.4.0     2.2.0     2.0.4     1.7.9
     2.3.9     2.1.9     2.0.3     1.7.8
     2.3.8     2.1.8     2.0.2     1.7.7
     2.3.7     2.1.7     2.0.1     1.7.6
     2.3.6     2.1.6     2.0.0     1.7.5
     2.3.5     2.1.5     1.8.9     1.7.4
     2.3.4     2.1.4     1.8.8     1.7.3
     2.3.3     2.1.3     1.8.7     1.7.2
     2.3.2     2.1.2     1.8.6     1.7.11
     2.3.11    2.1.1     1.8.5     1.7.10

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

バージョン指定してインストール

sdk install groovy 2.4.5

途中、一か所だけ(Y/n)を訊かれる(★の箇所)。
今回はデフォルトのバージョンとして使いたいので、Yを入力する。

output
Downloading: groovy 2.4.5
(中略)
Installing: groovy 2.4.5
Done installing!
Do you want groovy 2.4.5 to be set as default? (Y/n): ★Y
Setting groovy 2.4.5 as default.

確認

groovy -v

※JVMのバージョンは環境によって変わります

output
Groovy Version: 2.4.5 JVM: 1.7.0_40 Vendor: Oracle Corporation OS: Linux

改めてGroovyのバージョン一覧を見てみる

sdk list groovy

バージョン管理しやすい印象。(今すぐにはしませんが)

output
=====================================================================
Available Groovy Versions
=====================================================================
> *  2.4.5     2.3.10    2.1.0     1.8.4
     2.4.4     2.3.1     2.0.8     1.8.3
     2.4.3     2.3.0     2.0.7     1.8.2
     2.4.2     2.2.2     2.0.6     1.8.1
     2.4.1     2.2.1     2.0.5     1.8.0
     2.4.0     2.2.0     2.0.4     1.7.9
     2.3.9     2.1.9     2.0.3     1.7.8
     2.3.8     2.1.8     2.0.2     1.7.7
     2.3.7     2.1.7     2.0.1     1.7.6
     2.3.6     2.1.6     2.0.0     1.7.5
     2.3.5     2.1.5     1.8.9     1.7.4
     2.3.4     2.1.4     1.8.8     1.7.3
     2.3.3     2.1.3     1.8.7     1.7.2
     2.3.2     2.1.2     1.8.6     1.7.11
     2.3.11    2.1.1     1.8.5     1.7.10

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

コード書いてみる

Xを使わない環境

コード

hello.groovy
println "Hello World"

実行

groovy hello.groovy

出力

output
Hello World

Xが使える環境

たぶん、こうすればエディターが起動するはず

groovyConsole

参考

http://qiita.com/saba1024/items/967ee3d8a79440a97336
http://tomoyamkung.net/2015/09/26/gvm-gradle-install/

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1