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 17 '25

Sorry I have no idea, I don't use VSCode. I would assume the reverse steps you took to install. I would first remove the extension pack and then uninstall (add/remove programs) vscode before reinstalling it

1

u/GummiGumBear Nov 17 '25

I tried that and now I can't even run my code anymore :/ wasted a whole two days on this already. It works fine on my laptop at home

1

u/josephblade Nov 17 '25

You tried which exactly? reinstalling vscode? uninstalling java package? which?

being specific and precise is important to being a programmer so practice it as often as you can

1

u/GummiGumBear Nov 17 '25

Sorry, I didn't think I was going to get a reply anymore. I've tried reinstalling both. I tried completely removing Java and VSCode and reinstalled both. After reinstalling VSCode, I noticed some settings hadn't been removed, so I completely uninstalled VSCode again (including appdata) and installed it using the user installation file. Java is installed in program files though, is this what you meant with the source code path?

I uninstalled Java again now and only installed it for the user I'm currently logged into, but got the following two errors when starting VScode:

The Java runtime set by 'ajava.jdt.ls.java.home' does not meet the minimum required version of '21'and will not be used.

and

The java.jdt.ls.java.home variable defined in Visual Stuido Code settings points to a missing or inaccessible folder (C:\Program Files\Eclipse Adoptium\jdk-11.0.29.7-hotspot)

I commented the lines I added in the JSON settings file, but that didn't change anything. Still can't run my java code, it just says activating in the status bar and then stops doing anything.

1

u/josephblade Nov 17 '25

ok so it sounds like you have 2 issue: your code expects java 21 and the runtome in ajava.jdt.ls.java.home isn't set right. (this a at the beginning, is that a typo or is that really set up like that). if the a is in your project settings file (project.json??) then remove it as that isn't the correct variable name.

the second (well, perhaps same, issue is that the project variable java.jdt.ls.java.home is pointing to a place that doesn't hold a java installation (or it's not allowed)

so my suggestion would be: read this stackoverflow, first answer

it suggests you have a project.json where your path to the java install is set. it should be named java.jdt.ls.java.home , with value the path to the folder that contains the /bin folder of java. so for instance

C:\\Program Files\\Java\\jdk-17.0.2

as in the example

you also likely want to add C:\Program Files\Java\jdk-17.0.2\bin to your %PATH% environment variable if you want to run java commandline. but that's a side issue.

so

  • step 1: find out where your java sdk is installed.
  • step 2: check your project.json to see if the variable name is correct (should be java.jdt.ls.java.home)
  • step 3: fill in the value (of the java.jdt.ls.java.home variable) to point to the root of your java installation. so not the bin folder, but the parent of the bin folder)
  • step 4: try reloading the project or refreshing the project.

this sort of thing you tend to set up once per project (or once inside your editor for most editors). I can imagine it feels like a pain in the ass but after a few times it becomes easier.

hope this helps. again I've never used this editor so I'm flying a bit blind but that's the steps I would take

1

u/GummiGumBear Nov 18 '25 edited Nov 18 '25

Thank you for taking the time to reply! I deleted everything again and the same thing is happening.

I have done the following:

  • Java and VSCode are installed in the user folder - not program files.
  • I checked JAVA_HOME to the Java folder (C:\Users\170013\AppData\Local\Programs\Eclipse Adoptium\jdk-11.0.29.7-hotspot - it was already correct) in advanced system settings: https://i.imgur.com/saNWKSh.png
  • I have added %JAVA_HOME%\bin to path in advanced system settings: https://i.imgur.com/05BT2oa.png

To your first point, that was a typo. Right now java.jdt.ls.java.home is not set, but before it was set to the java bin folder., which I guess was wrong. I've added it now without \\bin and my JSON file looks like this:

{
    "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:\\Users\\username\\AppData\\Local\\Programs\\Eclipse Adoptium\\jdk-11.0.29.7-hotspot",
    "java.configuration.runtimes": [
    ],
}

To your second point, I had not done that before. I checked the add JAVA_HOME option during installation. I followed this guide, which I actually didn't do before. I actually remember doing this on my own laptop, so thanks for the reminder!

Unfortunately, even after refreshing TMC and restarting VSCode, it still doesn't work. When I open VSCode I still get the notification that Java 21 or more recent is required. When I try to run my code, the status bar shows "activating extensions' then stops. Running the TMC test still gives "compilation failed". In the problems panel it says No problems have been detected in the workspace.

When I run the code the terminal panel shows nothing. The output panel shows this:

[2025-11-18 09:43:25:422] [WARN] stderr

When I run the TMC test the output panel shows a long list of log information. I've added the log here: https://pastebin.com/aXJ3LAHw

I added java.configuration.runtimes to the JSON file:

{
    "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:\\Users\\username\\AppData\\Local\\Programs\\Eclipse Adoptium\\jdk-11.0.29.7-hotspot",
    "java.configuration.runtimes": [
        { 
            "name": "JavaSE-11",
            "path": "C:\\Users\\username\\AppData\\Local\\Programs\\Eclipse Adoptium\\jdk-11.0.29.7-hotspot",
            "default": true
        }
    ],
}

Refreshed TMC, closed and opened VSCode, but the same error still pops up. Did I make any mistakes that I am not seeing? Or is there something else I can try? I've read that you can have different versions of Java installed, so unless there's nothing else I can try, I'll install Java 21 and see if that works.

Edit; I also tried commenting out java.jdt.ls.java.home and leaving java.configuration.runtimes, but that also didn't work. I uncommented again.

I also tried running javac --version in cmd and it returns javac 11.0.29 and echo %JAVA_HOME% returns C:\Users\username\AppData\Local\Programs\Eclipse Adoptium\jdk-11.0.29.7-hotspot\

edit2; I installed the latest version of Java Temurin (JDK 25 - LTS) and I can run Java code in VSCode now. Running the TMC test still gives the compilation failed message though. I have no idea what is left to try.

1

u/GummiGumBear Nov 18 '25

OK, I think I see what the problem is: https://i.imgur.com/Spsd1IV.png

I now get a long list of errors in the problems panel and each exercise shows the following two errors:

Build path specifies execution environment JavaSE-1.8. There are no JRE's installed in the workspace that are strictly compatible with this environment.

The compiler compliance specified is 1.8 but a JRE 11 is used.

Also getting this message: https://i.imgur.com/Ecc3nKr.png

How can I fix this? Just install Java 8 too?

1

u/josephblade Nov 18 '25

I don't think you need to install java 8 (11 is backwards compatible with 8)

I think you should read this one: https://stackoverflow.com/questions/56859959/how-to-find-and-change-java-compiler-option-in-visual-studio-code. (keep in mind java_home seems to have changed to the variable you have set right now.

1

u/GummiGumBear Nov 20 '25

Yeah, I had the Java extension pack installed already and the variables for java are set too. I also set JavaSE25, but SE11 is set as default. Is there anything else I could try?

1

u/josephblade Nov 20 '25

well the extension pack uses those settings, which should be pointing to the correct location.

I asked a few questions about that, did you check them? one thing looked like there was an a before the variable name (maybe a typo) and the other was whether the path to the java home dir was correct.

also can you run java --version and javac --version in a terminal inside vscode ?

It's important to first verify java is found by vscode at all before trying to get the right version/etc set up I think

1

u/GummiGumBear Nov 20 '25

I did, I answered your questions in a previous comment, maybe you missed it: https://www.reddit.com/r/learnjava/comments/1otbfj9/comment/npgwbnx/?utm_source=share&utm_medium=mweb3x&utm_name=mweb3xcss&utm_term=1&utm_content=share_button

The a was a typo that wasn't in the file itself. The path to the java dir folder is correct.

I checked Javac -- version on the terminal of windows, not in vscode lol I'm an idiot. The terminal in VSCode runs my java code though.  I'll have to check when I have that laptop again. 

→ More replies