-
New switch Expressions in Java 12_java 17(에러메세지 해결) (use --enable-preview to enable patterns in switch statements)코딩Coding/Java&Kotlin 2022. 6. 5. 20:54728x90
https://blogs.oracle.com/javamagazine/post/new-switch-expressions-in-java-12
에러 메세지
src/Start.java:8: error: patterns in switch statements are a preview feature and are disabled by default. case Sleeping sl -> System.out.println("Wake up!" + sl.hours); ^ (use --enable-preview to enable patterns in switch statements)
java --enable-preview Start Start 는 컴파일 하고 나온 실행 파일 Start.class
17 뭐시기 에러나서 해결함.
오라클 들어가서
다운로드까지 ㅋㅋ
https://www.oracle.com/java/technologies/javase/jdk12-archive-downloads.html
12 로 해도 에러 나서
javac --enable-preview --release 12 Start.java error: invalid source release 12 with --enable-preview (preview language features are only supported for release 17)
17로 컴파일 해줌.
javac --enable-preview --release 17 Start.java Note: Start.java uses preview features of Java SE 17. Note: Recompile with -Xlint:preview for details.
ls Activity.class Coding.class Skiing.class Sleeping.class Start.class Start.java
java --enable-preview Start Wake up!9
성공 !!!
❤️
반응형'코딩Coding > Java&Kotlin' 카테고리의 다른 글
Java Functional❤️Programming Full Course | Amigoscode (0) 2022.06.25 Learn JAVA-Full Course❤️ (0) 2022.06.21 JDK 19: The new features in Java 19 (0) 2022.06.07 Java - 폴더 src, dist폴더에 따로 관리하기 (0) 2022.06.05 My Journey of Using Vim for Java Development- SeniorMars (0) 2022.06.01 java에서 char는 2bytes (0) 2022.04.24 문자 자료형(char, Character)에 대해서 알기! (0) 2022.02.13 Mac M1 Java install & Setting (0) 2022.01.27