1

(Note: to anyone downvoting, kindly tell me the reason so I can improve and not repeat it)

I followed the instructions given in Java Getting Started inside vscode, but it resulted in failure. I do not just want a, perhaps hacky, fix for this. I want to understand what is causing the problem.

I am on Ubuntu 19.04 64bit.
vscode version 1.38.1
I have all the basic java extensions included in the pack installed in vscode.
java --version returns :

java 12.0.2 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+10)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+10, mixed mode, sharing)

This is what I followed. getting-started

It first took me to the newly generated launch.json instead of directly running the code as stated in the procedure.
Here is my launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch) - Current File",
            "request": "launch",
            "mainClass": "${file}"
        },
        {
            "type": "java",
            "name": "Debug (Launch)-QuickStart",
            "request": "launch",
            "mainClass": "QuickStart"
        }
    ]
}

I went ahead and hit F5 on my file again and this is what I was met with

user@machine:$ cd /home/user/test/java/proj ; /usr/lib/jvm/java-12-oracle/bin/java -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=localhost:42535 --enable-preview -Dfile.encoding=UTF-8 -cp /home/user/.config/Code/User/workspaceStorage/db4b3a82ff379b93685473884410762c/redhat.java/jdt_ws/jdt.ls-java-project/bin QuickStart 
Error: Could not find or load main class QuickStart
Caused by: java.lang.ClassNotFoundException: QuickStart

Please help me understand this and thereby fix it. If I have missed out any crucial information, please ask in the comments and I will promptly add it.

Thank you

2
  • class should be public, shouldn't it? Commented Oct 8, 2019 at 9:14
  • True, i added a public in front, no change in result though. Commented Oct 8, 2019 at 9:33

1 Answer 1

-1

There might be two reason to not identifying Java

1.Might be java is not installed correctly

2.Or there are multiple version jdk installed so might be conflict

you could refer to here

Sign up to request clarification or add additional context in comments.

1 Comment

It was a bug in the vscode extension. One they fixed a week ago and will be released soon. Should i still answer my own question and accept it? Thanks anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.