MacにJava9を入れてjshellを動かすまでのメモ
環境
インストール
JDK 9 Early Access Releases — Project Kenai
完了して確認
$ /usr/libexec/java_home -V Matching Java Virtual Machines (5): 9, x86_64: "Java SE 9-ea" /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home 1.8.0_60, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home 1.7.0_79, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home 1.6.0_65-b14-468, x86_64: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home 1.6.0_65-b14-468, i386: "Java SE 6" /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
jshell起動 & エラー
$ export JAVA_HOME=`/usr/libexec/java_home -v 1.9` $ $JAVA_HOME/bin/jshell Exception in thread "main" java.lang.InternalError: Failed remote launch: com.sun.jdi.CommandLineLaunch (defaults: home=/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home, options=, main=, suspend=true, quote=", vmexec=java) -- {home=home=/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home, options=options=-classpath "/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/classes" -Xbootclasspath:"/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/modules/bootmodules.jimage", main=main=jdk.internal.jshell.remote.RemoteAgent 57612, suspend=suspend=true, quote=quote=", vmexec=vmexec=java} at jdk.jshell.JDIConnection.reportLaunchFail(JDIConnection.java:344) at jdk.jshell.JDIConnection.launchTarget(JDIConnection.java:310) at jdk.jshell.JDIConnection.open(JDIConnection.java:121) at jdk.jshell.JDIEnv.init(JDIEnv.java:49) at jdk.jshell.ExecutionControl.jdiGo(ExecutionControl.java:269) at jdk.jshell.ExecutionControl.launch(ExecutionControl.java:71) at jdk.jshell.JShell.executionControl(JShell.java:613) at jdk.jshell.ClassTracker$ClassInfo.getReferenceTypeOrNull(ClassTracker.java:81) at jdk.jshell.Unit.lambda$classesToLoad$3(Unit.java:266) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1422) at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:591) at jdk.jshell.Unit.classesToLoad(Unit.java:264) at jdk.jshell.Eval.lambda$compileAndLoad$13(Eval.java:559) at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:269) at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1422) at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:511) at jdk.jshell.Eval.compileAndLoad(Eval.java:560) at jdk.jshell.Eval.declare(Eval.java:462) at jdk.jshell.Eval.processMethod(Eval.java:386) at jdk.jshell.Eval.eval(Eval.java:128) at jdk.jshell.JShell.eval(JShell.java:350) at jdk.internal.jshell.tool.JShellTool.processCompleteSource(JShellTool.java:1540) at jdk.internal.jshell.tool.JShellTool.processSource(JShellTool.java:1528) at jdk.internal.jshell.tool.JShellTool.processSourceCatchingReset(JShellTool.java:514) at jdk.internal.jshell.tool.JShellTool.run(JShellTool.java:494) at jdk.internal.jshell.tool.JShellTool.resetState(JShellTool.java:429) at jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:265) at jdk.internal.jshell.tool.JShellTool.start(JShellTool.java:260) at jdk.internal.jshell.tool.JShellTool.main(JShellTool.java:250) Caused by: com.sun.jdi.connect.VMStartException: VM initialization failed for: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/bin/java -classpath /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/tools.jar:/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/classes -Xbootclasspath:/Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/modules/bootmodules.jimage -Xdebug -Xrunjdwp:transport=dt_socket,address=JMEN0520:57613,suspend=y jdk.internal.jshell.remote.RemoteAgent 57612 at com.sun.tools.jdi.AbstractLauncher$Helper.launchAndAccept(AbstractLauncher.java:193) at com.sun.tools.jdi.AbstractLauncher.launch(AbstractLauncher.java:132) at com.sun.tools.jdi.SunCommandLineLauncher.launch(SunCommandLineLauncher.java:223) at jdk.jshell.JDIConnection.launchTarget(JDIConnection.java:303) ... 31 more
/etc/hosts
にhostnameを登録して解決
[JDK-8131029] JShell: recover from VMConnection launch failure - Java Bug System
自分のマシンのホスト名を取得
$ uname -n
これを/etc/hosts
に127.0.0.1
で追加して完了
イケた
$ $JAVA_HOME/bin/jshell | Welcome to JShell -- Version 9-ea | Type /help for help -> /help Type a Java language expression, statement, or declaration. Or type one of the following commands: /list [all|start|history|<name or id>] -- list the source you have typed /seteditor <executable> -- set the external editor command to use /edit <name or id> -- edit a source entry referenced by name or id /drop <name or id> -- delete a source entry referenced by name or id /save [all|history|start] <file> -- save: <none> - current source; all - source including overwritten, failed, and start-up code; history - editing history; start - default start-up definitions /open <file> -- open a file as source input /vars -- list the declared variables and their values /methods -- list the declared methods and their signatures /classes -- list the declared classes /imports -- list the imported items /exit -- exit the REPL /reset -- reset everything in the REPL /reload [restore] [quiet] -- reset and replay relevant history -- current or previous (restore) /feedback <level> -- feedback information: off, concise, normal, verbose, default, or ? /prompt -- toggle display of a prompt /classpath <path> -- add a path to the classpath /history -- history of what you have typed /setstart <file> -- read file and set as the new start-up definitions /help -- this help message /? -- this help message /! -- re-run last snippet /<id> -- re-run snippet by id /-<n> -- re-run n-th previous snippet Supported shortcuts include: <tab> -- show possible completions for the current text Shift-<tab> -- for current method or constructor invocation, show a synopsis of the method/constructor -> /exit | Goodbye
MacにOracle Databaseを入れようとして頑張っみたけど・・
結果、諦めました。
会社で11gを使っていてローカルで検証やチューニングを試してみたいと思ったのがきっかけ。
(DBAじゃないので、色々出来ない)
諦めてVirtualBoxにUbuntuいれて、Oracle Databaseを入れてみた
VirtualBoxをVagrant経由で使う
vagrant、VirtualBoxのインストールは省略
ubuntuインストール
A list of base boxes for Vagrant - Vagrantbox.es
適当にubuntuの
vagrant box
を探す以下、boxを登録、作成
$ vagrant box add ubuntu14 https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box $ vagrant init ubuntu14
- IPを固定にして使いたいので
Vagrantfile
を編集
config.vm.network "private_network", ip: "192.168.125.125"
ubuntuに入る
$ vagrant ssh
ubuntuにdockerをインストール
$ sudo vi /etc/apt/sources.list.d/docker.list 以下を追記 -------------------------------------------------------------------- deb https://apt.dockerproject.org/repo ubuntu-trusty main -------------------------------------------------------------------- $ sudo apt-get update $ sudo apt-get install linux-image-extra-$(uname -r) $ sudo apt-get update $ sudo apt-get install docker-engine # Macだと起動時にエラーになった気がする。以下のどちらかで解決できたはずです。。 # $ sudo usermod -aG docker vagrant $ sudo usermod -aG docker ubuntu
Docker起動
$ sudo service docker start $ docker --version
DockerにOracle Database XE 11gをインストール&起動
$ sudo docker pull wnameless/oracle-xe-11g $ sudo docker run -d -p 49160:22 -p 49161:1521 wnameless/oracle-xe-11g
- 起動確認
$ sudo docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 919c59369a7c wnameless/oracle-xe-11g "/bin/sh -c '/usr/sbi" 13 minutes ago Up 13 minutes 8080/tcp, 0.0.0.0:49160->22/tcp, 0.0.0.0:49161->1521/tcp reverent_joliot
- 停止
$ sudo docker stop 919c59369a7c
919c59369a7c
- Githubの接続情報を元に
SQL Developer
からアクセスできるか試してみる
hostname: 192.168.125.125
port: 49161
sid: xe
username: system
password: oracle
接続テストには成功する、接続も成功する。でも警告がでた!
リクエストされた操作の実行中にデータベース警告が発生しました: ORA-28002: the password will expire within 7 days 28002. 00000 - "the password will expire within %s days" *Cause: The user's account is about to expire and the password needs to be changed *Action: change the password or contact the DBA ベンダー・コード28002
Oracleが起動したコンテナに入る
ssh root@localhost -p 49160 password: admin
/u01/app/oracle/product/11.2.0/xe/bin# ./sqlplus system/oracle@localhost/xe ---------------------------------------------------------------------------------------- SQL*Plus: Release 11.2.0.2.0 Production on Sat Jan 30 22:38:34 2016 Copyright (c) 1982, 2011, Oracle. All rights reserved. ERROR: ORA-28002: the password will expire within 7 days Connected to: Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production SQL> ALTER USER system IDENTIFIED BY oracle;
- (おまけ)パスワードの期限を無制限に設定 alter profile default limit password_life_time unlimited;
これで警告はなくなりました。。