목차

VSCode Java

설정 위치

JDK의 설치

"java.configuration.runtimes": [
	{
		"name": "JavaSE-1.8",
		"path": "/usr/lib/jvm/java-8-openjdk-amd64"
	},
	{
		"name": "JavaSE-11",
		"path": "/usr/lib/jvm/java-11-openjdk-amd64",
		"default": true
	},
	{
		"name": "JavaSE-17",
		"path": "/usr/lib/jvm/java-17-openjdk-amd64"
	}
],
"java.import.gradle.java.home": "/usr/lib/jvm/java-11-openjdk-amd64"

Java project 설정

"java.settings.url": "/home/<your_name>/settings.prefs"

Java --enable-preview

org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=enabled
plugins {
    // Apply the java-library plugin to add support for Java Library
    id 'java-library'
    id 'eclipse'
}
 
tasks.withType(JavaCompile) {
    options.compilerArgs += '--enable-preview'
}
tasks.withType(Test) {
    jvmArgs += "--enable-preview"
}
 
// buildship 은 아래를 실행하지 않는다.
// 따라서 gradlew eclipse 를 실행해줘야 한다.
eclipse.jdt.file.withProperties { props ->
    props['org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures']= 'enabled'
    props['org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures']= 'ignore'
}

java Formatter

"[java]": {
    "editor.defaultFormatter": "redhat.java"
},
"java.format.settings.url": "https://raw.githubusercontent.com/google/styleguide/gh-pages/eclipse-java-google-style.xml",
"java.format.settings.profile": "GoogleStyle",

Extensions

참조