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

Test build failure

Open sebastieng opened this issue 1 year ago • 5 comments
trafficstars

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

sebastieng avatar Jan 24 '24 13:01 sebastieng

@jdneo for a look.

testforstephen avatar Feb 04 '24 07:02 testforstephen

Could you share a sample project?

jdneo avatar Feb 04 '24 07:02 jdneo

@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",

sebastieng avatar Feb 05 '24 10:02 sebastieng

Hi @sebastieng,

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

jdneo avatar Feb 06 '24 05:02 jdneo

Thanks @jdneo . I confirm , it fix my issue

sebastieng avatar Feb 06 '24 11:02 sebastieng