sirin05137 / CSE364_Project

2 stars 0 forks source link

Java compiler version not matching in LOCAL #13

Closed yuujinleee closed 3 years ago

yuujinleee commented 3 years ago

(최종)코멘트 포함 한 줄 요약 :

도커 컨테이너 내에서 mvn -version 실행 시는 자바 버전이 11.0.10으로 맞게 나오지만, 로컬에서 실행 시에는 자바 버전이 15.0.2로 나오는 경우가 있습니다. 그에 따라서 pom.xml에서

<executable>"$JAVA_HOME"/bin/javac</executable>

이 와 같이 JAVA_HOME 경로를 직접 참조하는 코드를 추가하였으니 각자 로컬에서 JAVA_HOME 경로를 적절하게 JDK11의 경로에 맞춰주세요. (맥의 경우 Setting JAVA_HOME ENV variable on Mac 이 링크를 참조하면 쉽게 설정 가능합니다.)

-> 위에 코드 현재는 다시 제거 된 상태!

//-----요약 끝-----

1) When executed inside the docker container,

Java version: 11.0.10

root@e85c6bb51aec:~/project/CSE364_Project# mvn -version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: ko_KR, platform encoding: UTF-8
OS name: "linux", version: "4.19.121-linuxkit", arch: "amd64", family: "unix"

2) However when compiled(mvn install) in my local,

Java version: 15.0.2 😨 ?????!

yujinlee@Yujins-MacBook-Pro CSE364_Project % mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 15.0.2, vendor: N/A, runtime: /usr/local/Cellar/openjdk/15.0.2/libexec/openjdk.jdk/Contents/Home
Default locale: en_KR, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.3", arch: "x86_64", family: "mac"

I dont know why its happening.

I have also set the project dependency in InteliJ as JDK 11.0.10 as well

Right click on CSE364_Project folder > Open Module Settings > Dependencies

image

yuujinleee commented 3 years ago

I will look at pom.xml for the maven to use java 11 compiler as a default for now.

yuujinleee commented 3 years ago

I specified the path to java compiler (javac) in the pom.xml and it works well (on my local only ❗ )

it now prints Java version: 11.0.10 in my local when mvn -version

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <verbose>true</verbose>
          <fork>true</fork>
          <executable><!-- path-to-javac --></executable>
          <compilerVersion>1.3</compilerVersion>
        </configuration>
      </plugin>

Ref. Apache Maven Compiler Plugin - Compiling Sources Using A Different JDK

pom.xml (in my branch)

<executable>"$JAVA_HOME"/bin/javac</executable>

mvn -version

yujinlee@Yujins-MacBook-Pro CSE364_Project % mvn -version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 11.0.10, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-11.0.10.jdk/Contents/Home
Default locale: en_KR, platform encoding: UTF-8
OS name: "mac os x", version: "10.15.3", arch: "x86_64", family: "mac"

However❗

in order to maintain same java compiler version among us, I think you guys should also

1) set the JAVA_HOME ENV Variable on your local (make sure it points to JDK11.0.10?)

Setting JAVA_HOME ENV variable on Mac

2) and test whether it prints the right java version as well (mvn -version on local)

sanghun17 commented 3 years ago

mvn -version Apache Maven 3.6.3 Maven home: /usr/share/maven Java version: 11.0.10, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64

I checked my java version. thank you!

yuujinleee commented 3 years ago

Thanks @sanghun17 ! 😄

yuujinleee commented 3 years ago

CHECK Open Module Settings - Sources / Dependencies

-> 11.0.10인지 체크

Sources

image

Dependencies

image

(같은 창에서 왼쪽 SDK메뉴) Platform Settings - SDKs

image

11인지 체크 (15폴더는 걍 지워버리셈)