表è¨ã®éããä»(2015/06/26)ç¾å¨Kullaã¨ããããã¸ã§ã¯ãã§REPLæ©è½ãéçºããã¦ãã¦ãJava 9ã§(ä»æ´ãªãã)æè¼ãããäºå®ã§ã(jshellã¨å¼ã°ããããã)ã
以åã¯ãã®Java REPLã試ãã®ã大å¤ã ã£ã(@zephiransasããã®ããã°è¨äºãåç §)ããã§ãããä»ã¯ããªãç°¡åã«ããã¤ããªã¼ãã«ãã試ããã¨ãã§ãã¾ããKullaã®ã³ããã¿ã¼ã®@bitter_foxããã®ããã°ãåèã«ã¤ã³ã¹ãã¼ã«ãå¯è½ã§ãã
æ¦è¦ãæ¸ãã¨â¦
- Java 9 early accessçãå ¥æãã
- Project Kullaã®Jenkinsããææ°çã®ææç©ãå ¥æãã
- Java 9 eaã«ãã¹ãéã(
java -version
ã§java version "1.9.0-ea"
ã¨åºã¦ããã°ãã) java -jar kulla-0.xxx-yyyymmddhhmmss.jar
ã§èµ·åãã
ã§ä½¿ããã¨ãã§ãã¾ãã
以ä¸ã¯æ¨æ¥(2015/06/25)ã®ææ°ãã¼ã¸ã§ã³ãå ã«æ¸ãã¦ããã¾ãã
- Javaã®ãã¼ã¸ã§ã³ : 1.9.0-ea-b68
- Kullaã®ãã¼ã¸ã§ã³ : 0.610-20150625005844
èµ·åã®ä»æ¹
å ã»ã©ãæ¸ããéããJava 9 eaã«ãã¹ãéããä¸ã§ã次ã®ã³ãã³ãã§å®è¡ã§ãã¾ãã
$ java -jar kulla-0.610-20150625005844.jar | Welcome to JShell -- Version 0.610 | Type /help for help ->
çµäºã®ä»æ¹
ä¸ã®å®è¡çµæãè¦ãã°ãããã¨ããããã«ãã表示ããæ¹æ³ã/help
ã¨ããããããå¼ã³åºãã°ããã®ã«ããããããããã«ããè¦ãæ¹æ³ãããããªãã¦ãCtrl
+ D
ã§çµäºãã¦ããããã¾ãããã/x
ã§çµäºã§ãã¾ãã
-> /x | Goodbye $
ã³ãã³ã
ä¸è¨ã«ããããã«/help
ãããã¯/?
ã§è¦ããã¨ãã§ãã¾ãã
å 容ã¯@yy_yankããã®ããã°ã§ãè¦ããã¾ãã
JavaのREPL、project kullaがスッゴイ便利! - Javaプログラマーのはしくれダイアリー
æãããã使ããã®ãåæ²ãã¾ãã
ã³ãã³ã(ç縮形) | ã³ãã³ã | ã³ãã³ãã®å 容 |
---|---|---|
/? |
/help |
ãã«ãã表示ãã |
/x |
/exit |
Java REPLãçµäºãã |
- | ! |
ååã¨åãå¼ or ã³ãã³ããå®è¡ãã (ä¸è¨ã® /-1 ã¨åã) |
- | /-æ°å |
æå®ããæ°ã®ååã®å¼ or ã³ãã³ãã å®è¡ãã |
/r |
/reset |
å
¥åãããã¹ã¦ã®å¤æ°ãã¯ã©ã¹å®ç¾© ãªã©ãã¯ãªã¢ãã |
/h |
/history |
å ¥åããå±¥æ´ã表示ãã |
/v |
vars |
å®ç¾©ãããå¤æ°ã表示ãã |
/m |
/methods |
å®ç¾©ãããã¡ã½ããã表示ãã |
/c |
/classes |
å®ç¾©ãããã¯ã©ã¹ã表示ãã |
/o <file-name> |
/open <file-name> |
æå®ããããã¹ããã¡ã¤ã«ãèªã¿è¾¼ã¿ ã³ã³ãã¤ã«ãã |
/cp <path> |
classpath <path> |
ã©ã¤ãã©ãªã¼ãèªã¿è¾¼ã |
- | seteditor <editor-name> |
å¤é¨ã¨ãã£ã¿ã¼ãæå®ãã |
/e <name> |
/edit <name> |
æå®ããå¤æ°ãã¯ã©ã¹ãªã©ã®å®ç¾©ã æå®ããå¤é¨ã¨ãã£ã¿ã¼ã§ ç·¨éãã (è¨å®ãã¦ããªãå ´å㯠JShellTool ã¨ããSwingã£ã½ãã¨ãã£ã¿ã¼) |
`/d |
/drop <name> |
æå®ããå¤æ°ãã¯ã©ã¹ãªã©ã ã¯ãªã¢ãã |
/s [all or history] <file-name> |
save [all or history] <file-name> |
å
¥åããå±¥æ´ããã¹ã¦(all )ãããã¯ãã¹ããªã¼ã ã( history )ãæå®ãããã¡ã¤ã«ã«ä¿åãã |
- | /setstart <file-name> |
æå®ãããã¡ã¤ã«ãåæãã¼ãå®ç¾© ã¨ãã¦èªã¿è¾¼ã ( /r å®è¡ã®å¾ã«æå¹ã«ãªã) |
- | /savestart <file-name> |
æå®ãããã¡ã¤ã«ã«ããã©ã«ãã® åæãã¼ãå®ç¾©ãæ¸ãè¾¼ã |
/p |
/prompt |
ããã³ããã®åã«ãã-> ã®è¡¨ç¤ºæç¡ãåãæ¿ãã |
ãã使ããã®ã ãã¨è¨ã£ã¦ããã©ãå ¨é¨æ¸ãã¡ãã£ã(ã»Ï<)
å人çã«ã¯ãscalaã¨ãgroovyshã¨ãghciã使ã£ã¦ã¦ã
:q
-> çµäº:l
-> ãã¡ã¤ã«ã®ãã¼ã
çãªåä½ã«æ £ãã¦ãã¾ã£ã¦ããã®ã§ãåããã¦ãããããã£ãæ°ãããªãããªãããªãâ¦
ã2015/06/27 15:08 è£è¶³ãscalaã¯:quit
ã ã£ãâ¦ãã¾ããããã§è¨ãããã®ã¯ãå¤ãã®REPLã:
ã§å§ã¾ã£ã¦ãã¦ãKullaã/
ã§å§ã¾ããã¨ã«ã¡ãã£ã¨éåæãæãã¦ããã¨ãããã¨ã§ã
ã¨ãããã使ã£ã¦ã¿ã
ã§ã¯ãåç´ã«ä½¿ã£ã¦ã¿ããã¨æãã¾ãã
-> 1 | Expression value is: 1 | assigned to temporary variable $1 of type int
å¼1
ãå®è¡ãããã¨ã§1
ãå¾ããã¦ããããå¤æ°$1
ã«ä»£å
¥ããã¾ããã/r
ãå®è¡ããªãéã¯ã以åã®å¼ã®å®è¡çµæã¯ãã®$1
çãªå¤æ°ã§ã¢ã¯ã»ã¹ãããã¨ãã§ãã¾ãã
-> 1 + 1L + 1_000l | Expression value is: 1002 | assigned to temporary variable $2 of type long
Java7ããå°å
¥ãããæ°å¤ã®éä¸ã®_
ã使ããã¨ãå¯è½ã§ãã
-> $2 = 100 | Variable $2 has been assigned the value 100
ããå®è¡çµæã®å¤æ°ã«å¥ã®å¤ãä»£å ¥ã§ãã¡ãããã â¦(´ã»Ïã»ï½)
å®è¡çµæã®å¤æ°ã¯ãªãã¹ãfinal
ã£ã½ããã¦ã»ããã£ãæ°ãããªãããªãããªãã§ããâ¦
-> URL url = new URL("http://mike-neck.hatenadiary.com/") | Added variable url of type URL with initial value http://mike-neck.hatenadiary.com/ -> URI uri = url.toURI() | Added variable uri of type URI with initial value http://mike-neck.hatenadiary.com/
URL#toURI
ã¯URISyntaxException
ã¨ããæ¤æ»ä¾å¤ãæããããå¯è½æ§ã®ããã¡ã½ãããªã®ã§ãããç¹ã«try-catchãå
¥ããªãã¦ãå®è¡ã§ãã¾ãããã¡ãããtry-catchã§å®è¡ãããã¨ãå¯è½ã§ãããªããtry-catchã®ä¸ã®ãããã¯ã§ã¯å¼ã¯;
ã§çµäºããå¿
è¦ãããã¾ãã
-> try { >> URL u = new URL("https://google.com"); >> URI i = u.toURI(); >> printf(i.toString()); >> } catch (URISyntaxException e) { >> printf(e.toString()); >> } https://google.com
ãã¡ã¤ã«ãèªã¿è¾¼ã
ãã¦ãç¾å¨foo
ã¨ãããã£ã¬ã¯ããªã¼ã«ãã¦ãfoo
ãã£ã¬ã¯ããªã¼ããã®ãããªæ§é ã§ããã¨ãã¾ãã
foo â sample â 00-sample.txt
ããã¦ã00-sample.txt
ã®ä¸èº«ããããªæãã§èªåèªèº«ãæååã¨ãã¦èªã¿è¾¼ã風ã«ãã¦ããã¾ãã
import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths import java.nio.charset.StandardCharsets Path sample = Paths.get("sample/00-sample.txt") List<String> list = Files.readAllLines(sample, StandardCharsets.UTF_8)
ããã/o
ã³ãã³ãã§èªã¿è¾¼ã¿ã¾ãã
-> /r | Resetting state. -> /o sample/00-sample.txt -> /v | Path sample = sample/00-sample.txt | List<String> list = [import java.nio.file.Files, import java.nio.file.Path, import java.nio.file.Paths, import java.nio.charset.StandardCharsets, , , Path sample = Paths.get("sample/00-sample.txt"), List<String> list = Files.readAllLines(sample, StandardCharsets.UTF_8)]
è¦äºã«èªã¿è¾¼ããããã§ããã
jarãã¡ã¤ã«ãèªã¿è¾¼ã
jarãã¡ã¤ã«ãªã©ãèªã¿è¾¼ãã§è©¦ããã¨ãã§ãã¾ãã
ã¨ãããããå
ã»ã©ã®foo
ãã£ã¬ã¯ããªã¼ã®ä¸ã«æ¬¡ã®ããã«twitter4jãç½®ãã¦ããã¾ããããã¦Kullaãèµ·åãã¾ãããªããtwitter4j.propertiesã«ã¯consumer keyãsecretãaccess tokenãtoken secretãè¨è¿°ãã¦ããã¾ãã
foo ⣠twitter4j-core-4.0.4.jar â twitter4j.properties
次ã®ããã«ã³ãã³ããæ¸ãã¦ããã¾ãã
-> /cp twitter4j-core-4.0.4.jar | Path twitter4j-core-4.0.4.jar added to classpath -> import twitter4j.TwitterFactory -> import twitter4j.Twitter -> Twitter twitter = TwitterFactory.getSingleton() | Added variable twitter of type Twitter with initial value TwitterImpl{INCLUDE_MY_RETWEET=PostParameter{name='include_my_retweet', value='true', file=null, fileBody=null}} -> twitter.updateStatus("project Kullaãããã¤ã¼ã") | Expression value is: StatusJSONImpl{createdAt=Fri Jun 26 15:58:21 JST 2015, id=614326819064418305, text='project Kullaãããã¤ã¼ã',...çç¥ | assigned to temporary variable $1 of type twitter4j.Status ->
ããã§ãã¤ã¼ããããã¤ã¼ãããã¡ãã«ãªãã¾ãã
project Kullaãããã¤ã¼ã
— æç°çå (@mike_neck) June 26, 2015
jarãã¡ã¤ã«ãèªã¿è¾¼ãããã¨ããããã¾ãããããã¯ãããã¸ã§ã¯ãã§ä½æããjarãã¡ã¤ã«ãã¡ããã£ã¨è©¦ãã¦ã¿ããã¨ããªã©ã«æå¹ããããã¾ããã
ã2015/06/27 15:08 追è¨ã ããã«ã¯Javaãã¹ã¯ãªããã¨ãã¦ä½¿ããã¨ãã§ããããããã¾ããã
project Kullaã¯ã¾ã éçºä¸ã§ãã®ã§ãä»å¾åä½ãå¤ãã£ã¦ããããããã¾ããããæè²ç¨éãã¡ãã£ã¨ãããã¹ãç¨éãããã³ã¡ãã£ã¨ããã¹ã¯ãªããã®å®è¡ã«ç¨ãããã¨ãã§ãããã§ããã¾ããä»åã¯è©¦ãã¦ãã¾ããããJettyãªã©ã®webãµã¼ãã¼ãèµ·åãã¦ãã¡ãã£ã¨ããwebãµã¼ãã¼ã®ã¢ãã¯ã¨ãã¦ã使ããã¨ãã§ããããããã¾ããã
ããã