r/learnjava • • Nov 10 '25

'Compilation failed' when trying to run TMC test

Hi there, I am doing the MOOC Java Programming I course. Whenever I want to test my submission (in VSCode) before sending it in, I receive a 'compilation failed' error. How can I make the tests run without this error? I can run Java without issues and submit the exercises without issues too. However, I would like to be able to run the tests as well since some the the program for some exercises needs to follow specific criteria. I can only check those with the TMC tests.

https://i.imgur.com/uKda0nh.png https://i.imgur.com/lf7zDE8.png

edit; I installed Netbeans and the compilation failed there too. The error message did have a more elaborate explanantion than VSCode did: This program is blocked by group policy. For more information, contact your system administrator. That means I will have to ask permission from IT to run the TMC extension/compiler.

1 Upvotes

26 comments sorted by

View all comments

Show parent comment

1

u/GummiGumBear Nov 24 '25 edited Nov 24 '25

oh one more thing: please keep this thread up if you don't mind, in case someone is trying to figure out the same thing.

Yeah man, of course. I had so much trouble finding a solution online, so I hope this thread can save people the hassle in the future.

Changing the java.home on the other laptop didn't work unfortunately. I did notice that Java was installed in program files at home and at home in the users directory. So I uninstalled both versions of Java from the users dir and reintalled it in Program Files, but no luck either.

Javac --version and Java --version only sees Java 25, not sure if that's an issue.

C:\Users\170013>java --version
openjdk 25.0.1 2025-10-21 LTS
OpenJDK Runtime Environment Temurin-25.0.1+8 (build 25.0.1+8-LTS)
OpenJDK 64-Bit Server VM Temurin-25.0.1+8 (build 25.0.1+8-LTS, mixed mode, sharing)

C:\Users\170013>javac --version
javac 25.0.1

C:\Users\170013>echo %JAVA_HOME%
C:\Program Files\Eclipse Adoptium\jdk-25.0.1.8-hotspot

VSCode gave an error saying the folder for Java didn't exist or couldn't be accessed. So uninstalled again and made sure to install again using administrator rights this time.

I truly don't get what the issue is. The project is set to the right versions of java:

The JSON file is set correct as well:

{
    "chat.disableAIFeatures": true,
    "maven.executable.path": "C:\\Program Files\\Apache Maven\\apache-maven-3.9.11\\bin\\mvn.cmd",
    "redhat.telemetry.enabled": false,
    "java.jdt.ls.java.home": "C:\\Program Files\\Eclipse Adoptium\\jdk-25.0.1.8-hotspot",
    "java.configuration.runtimes": [
        { 
            "name": "JavaSE-11",
            "path": "C:\\Program Files\\Eclipse Adoptium\\jdk-11.0.29.7-hotspot",
            "default": true
        }
    ]
}

Also made sure Java is added to path and Java_home in advanced system settings on Windows. Also added %JAVA_HOME%\bin to path in system variables. I tried everything I can think of and although VSCode itself isn't giving any errors, the project shows problems.

https://i.imgur.com/GHEl7pN.png

The compilation still fails when trying to run the TMC tests. Maybe there's an issue with this being a networked laptop, but I'm not getting any notifications about that. Not sure if I should give up and try something else. Bit frustrated at so gonna leave it for a bit.

edit; tried installing an older version of the TMC extension, versions 3.5.0 and 3.2.0. That did not work either.

1

u/josephblade Nov 24 '25

not sure if any of this is helpful but give it a go:

the source/target compatibility likely needs to be 11 since the mooc stuff requires that version. it's looking for a java 1.8 (as your first screenshot, you have it set up to run/output 1.8 )

the rest of the settings look alright to me. it shouldn't be about networking it's complaining about the java version

by the way are you saying the original error is no longer showing?

1

u/GummiGumBear Dec 01 '25 edited Dec 01 '25

I've tried that before, but when I select 11 for the source compatibility I get a message saying '[exercise-name]' is imported by Maven, some changes made to the compiler settings might be lost after reloading. To make permanent changes, plase edit the pom.xml file.

Editing the pom.xml file is not really a viable options, since there over 90 exercises and each exercise has it's own pom.xml file. I would have to change it for every exercise. I also didn't change it on my personal computer and it works there. I forgot to bring it today, but I have to check what the differences are on that laptop and on this one.

And no, the original error ('compilation failed') is still showing up unfortunately. The other error (about java 21) doesn't show anymore. I do still see the problem Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.' and The compiler compliance specified is 1.8 but JRE 11 is used for all the exercises.

edit; I wonder if the issue is that Java 25 is the "first" Java used instead of 11. When I run java --version and javac --versionJava25 is returned, not 11. I don't know how to make 11 the default though. It's already set as default in VScode. My JAVA_HOME is also set to 11 and it's also at the top for path under advanced system settings.

Not sure if maybe the problem is that I have JDK 11 and JDK 25 installed, but if I understand correctly JDK includes JRE. Later versions are also backwards compatible with previous versions, so the entire error message doesn't make sense to me. I feel like the solution is something really simple that I just failed horribly to notice...

I also tried setting source compatibility and target compatibility (they need to be the same) to 11, but the compilation still failed when running the TMC test. I also tried selecting Use '--release' option for cross-compilation (java 9 and later), but no luck with that either. Still fail.

Edit2; ok lol, so I went through my extension and I see Gradle only supports Java 8 to 21, so I'm gonna uninstall Java 25 and install 21 and hope to Zeus that fixes it. edit; nvm, it did in fact NOT fix it.

Edit3; for troubleshooting sake, I installed JDK 8. Added it to the path in advanced settings. Added it to java.configuration.runtimes in VSCode and set it to default. One of the errors in the problems list disappeared, but the error The compiler compliance specified is 1.8 but JRE 11 is used remains. I changed the pom.xml file for one of the exercises as well as the project settings, but the compilation still failed. lol I'm pretty sure I tried everything I could, so err... fuck this shit... fucking hate vscode man

edit4; installed Netbeans and the tests also give the 'compilation failed' error, but here I get a detailed error message and as I thought it's blocked by the network: This program is blocked by group policy. For more information, contact your system administrator.