인텔리제이에서 jigsaw 코딩하기
인텔리제이에서는 일단 이클립스처럼 사전작업? 이런것은 할것이 없다. 물론 JDK는 9버전 이상으로 되야 된다.
먼저 프로젝트 생성후에 모듈 클릭

next

모듈명 입력 이클립스랑 똑같이 고고

module-info.java 가 생김

그럼 다시 2번째 모듈인 second를 생성
1 2 3 4 5 6 7 8 9
|
module second { exports second; }
|
그담에 second 패키지 생성후 아래의 코드를 작성함
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
package second;
public class User { private String name = "zolla";
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
|
그담에 first 프로젝트에 module-info.java 에 의존성 추가
1 2 3 4 5 6 7 8 9
|
module first { requires second; }
|
아래처럼 에러가남

그럼 아래의 메뉴에 프로젝트 스트럭쳐 클릭

그다음에 전 first에 의존성을 추가할꺼니

모듈 디펜던시 클릭

난 second가 필요하니 클릭

그럼 아래처럼 메뉴가 나온다

이렇게 되면 에러가 사라지고 다시 이클립스에서 했던것 처럼
나머지 코드는 first 프로젝트에 first 패키지에 아래 코드 생성후 테스트
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
package first;
import second.User;
public class Test {
public static void main(String[] args) { User zolla = new User(); System.out.println(zolla.getName()); }
}
|
터미널에 아래처럼 찍힘
1 2 3 4 5 6 7
| "C:\Program Files\Java\jdk-10.0.2\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.2\lib\idea_rt.jar=7607:C:\Program Files\JetBrains\IntelliJ IDEA 2018.1.2\bin" -Dfile.encoding=UTF-8 -p D:\jigsaw\IDEA\out\production\first;D:\jigsaw\IDEA\out\production\second -m first/first.Test zolla
Process finished with exit code 0
|
인텔리제이는 명시적으로 실행 명령어를 보여줘서 좋다고 생각함
그럼 끝
참조