ä»åãããJavaã«ãããã¶ã¤ã³ãã¿ã¼ã³ãå¦ãã§ããã¾ãã
ææã¯ãåèæç®ã®ãJavaè¨èªã§å¦ã¶ãã¶ã¤ã³ãã¿ã¼ã³å
¥é第3çãã§ãã
Eclipseã¯éãã®ã§ãVisual Studio Codeã§ãã£ã¦ããã¾ãã
ã¤ãã§ã«ãVisual Studio Codeã®æ¡å¼µæ©è½ã®PlantUMLã追å ãã¦ããã¾ãã
ä»åã¯ãJavaã®ç°å¢æ§ç¯ãè¡ãã¾ãã
ã§ã¯ããã£ã¦ããã¾ãããï¼
åèæç®
åèæç®ã®ãµã³ãã«ããã°ã©ã ã®ãã¦ã³ãã¼ã
www.hyuki.com
ã¯ããã«
ãJavaã§ãã¶ã¤ã³ãã¿ã¼ã³ãå¦ã¶ãã®è¨äºä¸è¦§ã§ããè¯ãã£ããåèã«ãã¦ãã ããã
Javaã§ãã¶ã¤ã³ãã¿ã¼ã³ã®è¨äºä¸è¦§
ä»æ´ã§ããããã¶ã¤ã³ãã¿ã¼ã³ãå¦ãã§ããã¾ãã
Javaè¨èªããã¶ã¤ã³ãã¿ã¼ã³ã¨ãã«ãå®å
¨ã«å¿ãã¦ãã¾ã£ãã®ã§ãå¦ã³ç´ãã§ãï¼ç¬ï¼
ææã¯ãåèæç®ã®ãJavaè¨èªã§å¦ã¶ãã¶ã¤ã³ãã¿ã¼ã³å
¥é第3çãã§ãã
èè
ã®çµå浩ããã¯ãæ°å¦ã¬ã¼ã«ãæ¸ãããæ¹ã§ããæãããã§ãã
ä»åã¯ãJavaè¨èªã®éçºç°å¢ã®æ§ç¯æé ãæ¸ãã¦ããã¾ãã
Javaéçºã¯ãä»ãEclipseãå®çªãªããã§ãããç§ã®å ´åã¯ãVisual Studio Codeï¼ä»¥ä¸ãVSCodeï¼ã«çµ¶è³ç§»è¡ä¸ãªã®ã§ãVSCodeã使ãã¾ãï¼
JDKã¤ã³ã¹ãã¼ã«æé
JDKã®ãã¦ã³ãã¼ã
JDKï¼Java Development Kitï¼ã¯ãJavaéçºãããã§ãJavaè¨èªã使ã£ãã½ããã¦ã§ã¢éçºãè¡ãã®ã«å¿
è¦ãªãã¼ã«ã1ã¤ã«ã¾ã¨ãã¦ããã¦ãããã±ã¼ã¸ã§ãã
Javaã®éçºå
ã®Oracle社ï¼ãã¨ãã¨ã¯ Sun Microsystems社ã ããOracle社ãè²·åããï¼ãç¡åé
å¸ãã¦ãã¦ã誰ã§ãèªç±ã«å
¥æã使ç¨ã§ãã¾ãï¼ï¼ããã¯ãOracle OpenJDKã®ãã¨ã§ããã¨ã¯OpenJDKã¯ãªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ãã¨ãã¦éçºããã¦ãã¦ãããããã¨ã«ããã®ããOracle OpenJDKã§ãï¼
ä¸æ¹ãJREï¼Java Runtime Environmentï¼ã¯ãJavaã®å®è¡ç°å¢ã§ãJavaä»®æ³ãã·ã³ï¼JavaVMï¼ãå
¥ã£ã¦ãã¦ãJavaãå®è¡ãããå ´åã«ä½¿ç¨ãã¾ãããç¾å¨ã¯ãJREåä½ã§ã¯æä¾ããã¦ãªãããã§ãã
JDKã¯JREãå«ãã§ããã®ã§ãJDKãã¤ã³ã¹ãã¼ã«ããã°ãJREã¯ä¸è¦ã§ãã
以ä¸ã«ã¢ã¯ã»ã¹ãã¾ãã
www.oracle.com
ææ°ã® JDK22 ãã¯ãªãã¯ãWindowsãã¯ãªãã¯ãã¾ãã
Windowsã®å ´åã以ä¸ã®ããã«ã3ã¤ã®é¸æè¢ãããã¾ãããã¤ã³ã¹ãã¼ã«æ¹æ³ãéãã ãã§ãã©ãã使ã£ã¦ãåãã ã¨æãã¾ãã
ä»åã¯ãä¸çªç°¡åãããªMSIã¤ã³ã¹ãã¼ã©å½¢å¼ããã¦ã³ãã¼ããã¾ããã
念ã®ããããã¦ã³ãã¼ããæ£ããåºæ¥ã¦ãããã©ãããããã·ã¥ããã§ãã¯ãã¦ããã¾ãã
MSIå½¢å¼ã®ãã¡ã¤ã«ã®å ´åã®ããã·ã¥ã¯ä»¥ä¸ã§ããã
7-Zip ã® SHA-256 ã使ã£ã¦ããã¦ã³ãã¼ããããã¡ã¤ã«ã®ããã·ã¥ãè¨ç®ãã¾ãã
åã£ã¦ã¾ãããå
¨é¨è¦ã¦ãªãã§ããã©ï¼ç¬ï¼ã
JDKã®ã¤ã³ã¹ãã¼ã«æé
ãã¦ã³ãã¼ããããã¡ã¤ã«ãjdk-22_windows-x64_bin.msiããããã«ã¯ãªãã¯ãã¾ãã
é¸æè¢ã¯ãªãã®ã§ãNextãã¯ãªãã¯ãã¾ãã
ã¤ã³ã¹ãã¼ã«å
ãæå®ãããã¨ãåºæ¥ã¾ããå¿
è¦ãªããã°ãNextãã¯ãªãã¯ãã¾ãã
ã¤ã³ã¹ãã¼ã«å®äºã§ããæã£ãããç°¡åã§ããï¼ç¬ï¼
Visual Studio Code ã® Javaéçºç°å¢ã®ã»ããã¢ãã
VSCodeãèµ·åãã¦ãæ¡å¼µæ©è½ãéãã¾ãã
ä¸å³ã®å
¥åã«ãExtension Pack for Java
ã¨å
¥åãã¦ããã®ä¸ã®ã¤ã³ã¹ãã¼ã«ãã¯ãªãã¯ãã¾ãã
å®äºã§ãã試ãã«ãã¿ã¼ããã«ã§ãã¤ã³ã¹ãã¼ã«ãã Java ãåä½ãããã¨ã確èªãã¾ãã
Java version "22" ã¨è¡¨ç¤ºããã¦ãã¾ããæåã§ãã
Visual Studio Code 㧠Java ã®åä½ç¢ºèª
ã§ã¯ãåä½ç¢ºèªãã¦ããã¾ããããããããJavaã®ã½ã¼ã¹ã³ã¼ããªã©ãç½®ããã£ã¬ã¯ããªã決ãã¦ããã¾ãã
Ctrl+Shift+pãæ¼ãã¦ãã³ãã³ããã¬ãããéãã¾ãã
ãjavaãã¨å
¥åããã¨ãé¢é£ã®ã³ãã³ããåºã¦ãã¾ãã
ãjava: Create Java Project...ããã¯ãªãã¯ãã¾ãã
次ã«ããNo build toolsããã¯ãªãã¯ãã¾ããããã¯ããã«ããã¼ã«ãå«ã¾ãªãããã¸ã§ã¯ãã¨ããæå³ã§ããä»åã¯ãããé¸ã³ã¾ãã
ãã©ã«ããé¸æãããã¤ã¢ãã°ã表示ããã¾ãã®ã§ãå
ã»ã©æ±ºããJavaã®ã½ã¼ã¹ã³ã¼ããªã©ãç½®ããã£ã¬ã¯ããªãæå®ãã¾ãã
ããã¸ã§ã¯ãåãå
¥åãã¾ããä»åã¯ãhelloãã¨å
¥åãã¦Enterãã¼ãæ¼ãã¾ããããã¸ã§ã¯ãåã¯ã好ã¿ã§æå®ãã¦ãã ããã
å
ã»ã©æ±ºããJavaã®ã½ã¼ã¹ã³ã¼ããªã©ãç½®ããã£ã¬ã¯ããªã«ããhelloãã¨ãããã£ã¬ã¯ããªãä½ããããã®ä¸ã«ãJavaã®ã½ã¼ã¹ã³ã¼ãããé¢é£ã®ãã¡ã¤ã«ãä½ããã¾ãã
ãsrcãã®ä¸ã®ãApp.javaãã¨ãããã¡ã¤ã«ãããã«ã¯ãªãã¯ãã¾ãï¼ã·ã³ã°ã«ã¯ãªãã¯ã§ãéãã¾ããããã®å ´åã¯å¥ã®ãã¡ã¤ã«ãéãã¨ãApp.javaãã¯éãããã¾ãï¼ããApp.javaããéãã¾ããã
æ©éå®è¡ãã¦ã¿ã¾ããã¡ãã¥ã¼ã®å®è¡âãããã°ãªãã§å®è¡ãã¯ãªãã¯ãã¾ãã
ããã¨ãã¿ã¼ããã«ã«ãHello, World!ãã表示ããã¾ãããç¡äºã«å®è¡ã§ããããã§ãã
Visual Studio Codeã«PlantUMLã®æ©è½æ¡å¼µã追å
ã¤ãã§ã«ãããã¹ãã§UMLã®å³ãæ¸ãããPlantUMLããå
¥ãã¦ããã¾ãã
PlantUMLãVisual Studio Codeã§ä½¿ãã«ã¯ãJavaã®JDKã¨ãGraphvizã®ã¤ã³ã¹ãã¼ã«ãå¿
è¦ã§ãã
JDKã¯ã¤ã³ã¹ãã¼ã«ããã®ã§ãGraphvizãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãã
Graphvizã®ã¤ã³ã¹ãã¼ã«
ãã¦ã³ãã¼ãã¯ä»¥ä¸ã§ãã
www.graphviz.org
å°ãä¸ã«ã¹ã¯ãã¼ã«ããã¨ããã«ãWindowsç¨ã®ã¤ã³ã¹ãã¼ã©ãè¦ã¤ããã¾ãã
ããã·ã¥ããã§ãã¯ãã¦ããã¾ãã
ãã¦ã³ãã¼ããµã¤ããæä¾ãã¦ããSHA-256ã¯ä»¥ä¸ã§ããã
ãã¦ã³ãã¼ãããã¤ã³ã¹ãã¼ã©ã¼ã®SHA-256ãã7-Zipã§è¨ç®ããã¨ããã以ä¸ã§ããã
ãã¶ãä¸è´ãã¦ã¾ãï¼
æ©éã¤ã³ã¹ãã¼ã«ãã¦ããã¾ããã¤ã³ã¹ãã¼ã©ãããã«ã¯ãªãã¯ãã¾ãã
ã¤ã³ã¹ãã¼ã©ãèµ·åããã®ã§ãã次ã¸ããã¯ãªãã¯ãã¾ãã
ã©ã¤ã»ã³ã¹ã®æ³¨ææ¸ããåºã¾ããåé¡ãªããã°ããåæããããã¯ãªãã¯ãã¾ãã
ãã¹ã追å ããç»é¢ã«ãªãã¾ããã好ã¿ã§ããã§ããããã¹ãéãã¦ãªãã¨ä½¿ãã«ããã®ã§ãç§ã®å ´åã¯ãå
¨ã¦ã¼ã¶ã«è¿½å ãã¾ããã
次ã¯ãã¤ã³ã¹ãã¼ã«å
ã®æå®ã§ãããã®ã¾ã¾ã«ãã¾ãããã次ã¸ããã¯ãªãã¯ãã¾ãã
次ã¯ãããã°ã©ã ã¡ãã¥ã¼ã«è¿½å ããç»é¢ã§ããåé¡ãªããã°ããã¤ã³ã¹ãã¼ã«ããã¯ãªãã¯ãã¾ãã
ç¡äºã«ã¤ã³ã¹ãã¼ã«ãå®äºãã¾ããã
Visual Studio Codeã«PlantUMLã®æ©è½æ¡å¼µã追å
ç¶ãã¦ãVSCodeã«ãPlantUMLã®æ©è½æ¡å¼µã追å ãã¦ããã¾ãã
ãµã¤ããã¼ã®æ©è½æ¡å¼µã®ã¢ã¤ã³ã³ãæ¼ãã¦ãPlantUMLã¨å
¥åãã¦ãã¤ã³ã¹ãã¼ã«ãã¯ãªãã¯ãã¾ãã
ä¸å¿ãVSCodeãåèµ·åãã¦ããã¾ãã
ã§ã¯ãæ©é使ã£ã¦ã¿ã¾ãããï¼
PlantUMLã®ä½¿ãæ¹ã¯ãå
¬å¼ãµã¤ããåãããããã§ãã
plantuml.com
試ãã«ä»¥ä¸ãæ¸ãã¦ã¿ã¾ããã次åã§ä½¿ç¨ããã½ã¼ã¹ã³ã¼ãã®ã¯ã©ã¹ã§ãã
@startuml
class Book {
- String name
+ Book()
+ String getName()
}
@enduml
PlantUMLã®ãã¡ã¤ã«ã¯ã.puãã¨ããæ¡å¼µåã«ãã¾ãã
ããã¾ã§æ¸ããããå³ãçæããã¾ãã
ã³ãã³ããã¬ããï¼Ctrl+Shift+pï¼ãéãã¦ããPlantãã¨å
¥åããã¨ãPlantUMLã®ã³ãã³ããããã¤ãåºã¦ãã¾ãããã®ä¸ã®ãPlantUML: Preview Current Diagramããã¯ãªãã¯ãã¾ãã
ç¡äºã«ãã¯ã©ã¹å³ãçæããã¾ããã
æå¾ã«ã¨ã¯ã¹ãã¼ããã¦ãpngãã¡ã¤ã«ã«ãã¦ã¿ã¾ãã
ã¾ããåºåå
ã®ãã£ã¬ã¯ããªãæå®ãã¾ãã
æå®ããªããã°ãã¯ã¼ã¯ã¹ãã¼ã¹ã®outãã£ã¬ã¯ããªã«åºåããã¾ããç§ã®å ´åã¯ãPlantUMLã®ã½ã¼ã¹ãã¡ã¤ã«ã¨åããã£ã¬ã¯ããªã«åºåãã¦ã»ããã®ã§ãè¨å®ãå¤æ´ãã¾ãã
è¨å®ãéãããplantãã¨å
¥åããã¨ããPlantuml: Export Out Dirãã¨ããã®ãè¦ã¤ããããoutãã¨å
¥åããã¦ããã¨æãã¾ãããããã.ãã¨ãã«ã¬ã³ããã£ã¬ã¯ããªã®æå®ã«å¤æ´ãã¾ãã
ããã«ããPlantuml: Export Sub Folderãã§ãµããã©ã«ããä½ããã¦ãã¾ãã®ã§ããã§ãã¯ãå¤ãã¾ãããã®ãããã¯ãã好ã¿ã§ã©ããï¼
ã§ã¯ãæºåã§ããã®ã§ãã¨ã¯ã¹ãã¼ããã¦ããã¾ãããï¼
ã³ãã³ããã¬ããï¼Ctrl+Shift+pï¼ãéãã¦ããPlantãã¨å
¥åãããPlantUML: Export Current Diagramããã¯ãªãã¯ãã¾ãã
ã¨ã¯ã¹ãã¼ãããç»åãã¡ã¤ã«ã®å½¢å¼ãæå®ãã¾ããä»åã¯ãpngããæå®ãã¦ã¿ã¾ãã
ããã¨ãããã¤ã¢ã°ã©ã ã®ã¨ã¯ã¹ãã¼ããå®äºãã¾ãããã¨ããã¡ãã»ã¼ã¸ãåºåãããç»åãã¡ã¤ã«ãåºåããã¾ããã
ä»åã¯ä»¥ä¸ã§ãï¼
ãããã«
ä»åã®æé ã§ã¯ãVSCodeã«ãã¹ãè¨å®ããæé ãæ¸ãã¾ããã§ããã
JDKã®ã¤ã³ã¹ãã¼ã«ã§ãMSIå½¢å¼ã®ã¤ã³ã¹ãã¼ã©ã¼ãé¸ã¶ã¨ãèªåçã«ãã¹ãè¨å®ãããããã§ããVSCodeãããã¹ãéã£ã¦ããã°ãæ®éã«å®è¡ã§ãã¾ãã
ãããå®è¡ã§ããªããªã©ããã°ãVSCodeã«ãã¹ãè¨å®ãã¦ã¿ã¦ãã ããã
ä»åã¯ä»¥ä¸ã§ãï¼
æå¾ã¾ã§ãèªã¿ããã ãããããã¨ããããã¾ããã