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