vscode-java icon indicating copy to clipboard operation
vscode-java copied to clipboard

Java Language Support not working for Codespaces

Open FRC9289 opened this issue 1 year ago • 7 comments
trafficstars

We are a team that's running the First Robotics Competition and we want to sync our code between different devices. We chose GitHub codespaces since we already using GitHub. Everything works fine except Java language support kind of not able to find java image image We tried >add dev and add new java configuration to the codespace, but it didn't fix the problem

Is there any way to add Java to code spaces or let the extension recognize our local Java? That will be super helpful!

FRC9289 avatar Mar 05 '24 05:03 FRC9289

We have found issues that are potential duplicates:

  • #3493 (69.29%)

If any of the issues listed above are a duplicate, please consider closing this issue & upvoting/commenting the original one. Alternatively, if neither of the listed issues addresses your feature/bug, keep this issue open.

github-actions[bot] avatar Mar 05 '24 05:03 github-actions[bot]

We have found issues that are potential duplicates:

  • #3493 (69.29%)

If any of the issues listed above are a duplicate, please consider closing this issue & upvoting/commenting the original one. Alternatively, if neither of the listed issues addresses your feature/bug, keep this issue open.

github-actions[bot] avatar Mar 05 '24 05:03 github-actions[bot]

Have you looked at the codespaces+java documentation?

@testforstephen or @jdneo might be more familiar with running on codespace

fbricon avatar Mar 05 '24 08:03 fbricon

"java.jdt.ls.java.home" setting is machine scope, and it cannot be shared across devices. In the context of GitHub Codespaces, this setting can only point to a path within the GitHub Codespaces development machine.

testforstephen avatar Mar 05 '24 08:03 testforstephen

I've tried https://github.com/microsoft/vscode-remote-try-java and while it runs fine on codespaces, It failed to run as a devcontainer locally, with a similar issue as @FRC9289's (failing to use the java.jdt.ls.java.home value from my own user settings.json, in the container). To fix the problem, I changed https://github.com/microsoft/vscode-remote-try-java/blob/main/.devcontainer/devcontainer.json#L18-L26 to override the vscode settings running in that container: set the java.jdt.ls.java.home path to a proper value, and override java.configuration.runtimes to an empty array :

// Configure tool-specific properties.
"customizations": {
	// Configure properties specific to VS Code.
	"vscode": {
		"settings": {
			"java.jdt.ls.java.home": "/usr/lib/jvm/msopenjdk-current",
			"java.configuration.runtimes": []
		},
		"extensions": [
			"jbangdev.jbang-vscode"
		]
	}
}

fbricon avatar Mar 05 '24 09:03 fbricon

We gave up on using codespaces and changed to git now, thanks for everyone's help!

FRC9289 avatar Mar 07 '24 19:03 FRC9289

I've tried https://github.com/microsoft/vscode-remote-try-java and while it runs fine on codespaces, It failed to run as a devcontainer locally, with a similar issue as @FRC9289's (failing to use the java.jdt.ls.java.home value from my own user settings.json, in the container). To fix the problem, I changed https://github.com/microsoft/vscode-remote-try-java/blob/main/.devcontainer/devcontainer.json#L18-L26 to override the vscode settings running in that container: set the java.jdt.ls.java.home path to a proper value, and override java.configuration.runtimes to an empty array :

// Configure tool-specific properties.
"customizations": {
	// Configure properties specific to VS Code.
	"vscode": {
		"settings": {
			"java.jdt.ls.java.home": "/usr/lib/jvm/msopenjdk-current",
			"java.configuration.runtimes": []
		},
		"extensions": [
			"jbangdev.jbang-vscode"
		]
	}
}

I tried this (adding the java home path in customizations.vscode.settings.java.jdt.ls.java.home), but it's not working for me. I still get the same error message that the variable isn't defined. I'm using devcontainer.json on my local machine to make the container. Any more ideas?

adjenks avatar Sep 26 '24 23:09 adjenks