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

Test build failure #1431

Open
sebastieng opened this issue Jan 24, 2024 · 5 comments
Open

Test build failure #1431

sebastieng opened this issue Jan 24, 2024 · 5 comments

Comments

@sebastieng
Copy link

sebastieng commented Jan 24, 2024

Hello
I have a java project with gradle build.

I want to build with Java 8. My code used packages removed in java 11, for example javax.xml.bind.JAXBContext

So , in my build.gradle, I have

    java {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }

And I can run gradle tasks build/check/test using the vscode gradle side bar item without issues.

But when I try to launch a test using Test runner, the gradle build fails with "error: package javax.xml.bind does not exist"
So it seems to build with Java 11!
So why? Does test runner uses another gradle version (where java sourceCompatibility/targetCompatibility is not supported)?
Does a workaround exists?
I checked also Command -> Configure java runtime , and I have Java 1.8 configured too.

Environment
  • Operating System: VScode is running on Windows 10 with a remote-ssh to a Linux workstation
  • JDK version: 1.8
  • Visual Studio Code version: 1.85.2
  • Java extension version: 0.25.15
@testforstephen
Copy link
Contributor

@jdneo for a look.

@jdneo
Copy link
Member

jdneo commented Feb 4, 2024

Could you share a sample project?

@sebastieng
Copy link
Author

sebastieng commented Feb 5, 2024

@jdneo
See attached
SampleGradleProject.zip

I don't know if it is related but in my settings file, I have also

  "java.import.gradle.wrapper.enabled": false,
    "java.import.gradle.version": "7.6.3",

@jdneo
Copy link
Member

jdneo commented Feb 6, 2024

Hi @sebastieng,

Please try to set java.import.gradle.java.home to your jdk 8 installation path and reload your vscode.

@sebastieng
Copy link
Author

Thanks @jdneo .
I confirm , it fix my issue

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

3 participants