skip to Main Content

Quick disclaimer: It’s my 1st day at work and the following project has been written by my superior. All of this is very new to me so thank you for being patient.

Now to the point. So I received a java project that uses jdk 17. So today I tried to run it in VSCode using the Java Language Support and Java Debugger extensions. It showed some critical errors.
vscode showing error

So when I right clicked it and chose ‘Run Java’ on my ‘RifseepApplication.java’, it showed lots of compiling errors and the application crashed.
the errors

But when I open the exact project in Inteliji, it detects no errors in the code and I can run it perfectly.

So jdk version in Inteliji was set to 17 for the project, so I tried to change jdk version in VScode too. I added to ‘settings.json’:

{   "java.jdt.ls.java.home": "C:\Program Files\Eclipse Adoptium\jdk-17.0.4.101-hotspot",
    "java.configuration.runtimes": [
        {
        "name": "JavaSE-17",
        "path": "C:\Program Files\Eclipse Adoptium\jdk-17.0.4.101-hotspot"
        }
    ]
}

And when I check in the terminal, the jdk and java version are all good
But the editor is still showing errors in the code and I still can’t compile and run my application.
If someone has some insights to this, please share.
Thank you.

2

Answers


  1. Chosen as BEST ANSWER

    That was very dumb of me. The problem was indeed the wrong package declration for "...presentation.controllers.dto". It wasn't in the right place. Seems like somehow Inteliji has data of the previous build of this project so it can still runs fine. There wasn't any version problem with VScode or anything.


  2. Start by looking at what quick fix the little yellow light bulb next to the red squiggly line offers.

    enter image description here

    Then according to your screenshot,the level after your package is not the same as your actual directory level. Please modify to the correct directory structure.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search