Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot jdtcompile for java 11 #551

Closed
yimingwangdell opened this issue Sep 6, 2023 · 1 comment
Closed

cannot jdtcompile for java 11 #551

yimingwangdell opened this issue Sep 6, 2023 · 1 comment

Comments

@yimingwangdell
Copy link

yimingwangdell commented Sep 6, 2023

LSP client configuration

-- See :help vim.lsp.start_client for an overview of the supported config options.
local config = {
-- The command that starts the language server
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
cmd = {
-- 💀
-- '/usr/lib/jvm/java-20-openjdk/bin/java', -- or '/path/to/java17_or_newer/bin/java'
-- depends on if java is in your $PATH env variable and if it points to the right version.
'java',
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product',
'-Dlog.protocol=true',
'-Dlog.level=ALL',
'-Xmx1g',
'--add-modules=ALL-SYSTEM',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',

	-- 💀
	'-jar',
	os.getenv("HOME") .. '/Downloads/jdtls26/plugins/org.eclipse.equinox.launcher_1.6.500.v20230717-2134.jar',
	-- os.getenv("HOME") .. '/Downloads/jdtls19/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar',


	-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                       ^^^^^^^^^^^^^^
	-- Must point to the                                                     Change this to
	-- eclipse.jdt.ls installation                                           the actual version


	-- 💀
	'-configuration', os.getenv("HOME") .. '/Downloads/jdtls26/config_linux/',
	-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        ^^^^^^
	-- Must point to the                      Change to one of `linux`, `win` or `mac`
	-- eclipse.jdt.ls installation            Depending on your system.


	-- 💀
	-- See `data directory configuration` section in the README
	'-data', os.getenv("HOME") .. '/workspace/jdtls'
},

-- 💀
-- This is the default if not provided, you can remove it. Or adjust as needed.
-- One dedicated LSP server & client will be started per unique root_dir
root_dir = require('jdtls.setup').find_root({ 'build.gradle' }),

-- Here you can configure eclipse.jdt.ls specific settings
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
-- for a list of options
settings = {
	java = {
		configuration = {
			runtimes = {
				{
					name = "JavaSE-11",
					path = "/usr/lib/jvm/java-11-openjdk/",
				},
				{
					name = "JavaSE-17",
					path = "/usr/lib/jvm/java-17-openjdk/",
				},
			}
		}
	}
},

-- Language server `initializationOptions`
-- You need to extend the `bundles` with paths to jar files
-- if you want to use additional eclipse.jdt.ls plugins.
--
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
--
-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
init_options = {
	bundles = {}
},

}

-- This starts a new client & server,
-- or attaches to an existing client & server depending on the root_dir.
require('jdtls').start_or_attach(config)

Eclipse.jdt.ls version

org.eclipse.equinox.launcher_1.6.500.v20230717-2134.jar

Steps to Reproduce

open a java file of project with java 11 and gradle 5.6.4

Expected Result

able to compile

Actual Result

in console
Can't use Java 20.0.2 and Gradle 7.4.2 to import Gradle project

in log
message = "Sep 6, 2023, 6:30:40 PM Error occured while building workspace. Details: \n message: The supplied phased action failed with an exception.\nExecution failed for task ':buildSrc:compileGroovy'.\nBUG! exception in phase 'semantic analysis' in source unit ..............................Unsupported class file major version 64\nUnsupported class file major version 64; code: 0; resource: ..............................;\n message: Can't use Java 20.0.2 and Gradle 7.4.2 to import Gradle project ....; code: 0; resource: ................................; line: 1", type = 1 }

question

I have no idea why it use 20.0.2 and 7.4.2 ?? I haven't install them though.
is it a BUG as log said? is java 11 supported as documentation said?

@mfussenegger
Copy link
Owner

is java 11 supported as documentation said?

eclipse.jdt.ls itself requires at least java 17
You can use it to work on projects with a lower java source-/targetCompatibility but at least the gradle version needs to be compatible with java 17. At least until eclipse-jdtls/eclipse.jdt.ls#2812 - I think after that it tries to detect a compatible version.

@mfussenegger mfussenegger closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants