redhat-developer / vscode-java

Java Language Support for Visual Studio Code
Eclipse Public License 2.0
2.06k stars 420 forks source link

Java Language Support not working for Codespaces #3516

Open FRC9289 opened 4 months ago

FRC9289 commented 4 months ago

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!

github-actions[bot] commented 4 months ago

We have found issues that are potential duplicates:

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] commented 4 months ago

We have found issues that are potential duplicates:

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.

fbricon commented 4 months ago

Have you looked at the codespaces+java documentation?

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

testforstephen commented 4 months ago

"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.

fbricon commented 4 months ago

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"
        ]
    }
}
FRC9289 commented 4 months ago

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