I have a project in Java that it is a Main.java. Inside I have an import from a jar that…
- User
I have a project in Java that it is a Main.java. Inside I have an import from a jar that I have and that it is inside a folder at the same level of the file, like: / / Main.java / folder/myJar.jar I would built this project and run it. Any idea about how to do? I am on Debian 12, VSCode with Java Extension Pack, OpenJDK 17.
- Assistant
- User
I build it and run using terminal command. However, trying this configuration in launch.json does not work: { "version": "0.2.0", "configurations": [ { "type": "java", "name": "Launch Main", "request": "launch", "mainClass": "Main", "classPaths": [ ".:lib/*", ] } ] } This is the error I get: /usr/bin/env /usr/lib/jvm/java-17-openjdk-amd64/bin/java -XX:+ShowCodeDetailsInExceptionMessages -cp /.:lib/* Main Error: Could not find or load main class Main Caused by: java.lang.ClassNotFoundException: Main Do you know what can be the cause?
- Assistant
The error you're seeing indicates that the Java launcher cannot find the
Mainclass. This is likely because the classpath is not correctly configured. Let's go through a more refined setup for yourlaunch.jsonfile to ensure it's correctly pointing to your compiled class and the JAR dependencies.Correct
launch.jsonfor VSCodeIn VSCode, the
launch.jsonconfiguration for a Java project needs to be specific about the paths, especially concerning the compiled files and dependencies. To resolve your issue, try the following configuration: - User
I modify the launch.json, however I am getting the following pop-up: Build failed, do you want to continue? from Source: Debugger for Java, when I run the launch command from the launch button. Any idea?
- Assistant
- User
The strange fact is that if I do Continue it works correctly.
- Assistant