I am making my first steps with java, after some extensive experiences with python. The script I am running is a simple Java Swing Gui, that compiles and runs fine from the command line and within VS Code.
To set up the java debug environment, I used the lauch.json settings suggested on the github site https://github.com/k--kato/vscode-javadebug.
Unfortunately, every time I open the folder that contains the script, I get the following error message:
Warn: Classpath is incomplete. Only syntax errors will be reported.
I have no idea if the problem comes from within VS Code, of if it's some other configuration issue, such as the java set up....
My working platform is Linux Ubuntu, Gnome Shell.
Can anybody help?
This is the script:
//file name = SimpleEx.java import java.awt.EventQueue; import javax.swing.JFrame; public class SimpleEx extends JFrame { public SimpleEx() { initUI(); } private void initUI() { setTitle("Simple example"); setSize(300, 200); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { EventQueue.invokeLater(() -> { SimpleEx ex = new SimpleEx(); ex.setVisible(true); }); } }
and this is my launch.json:
{ "version": "0.2.0", "configurations": [ { "name": "Java", "type": "java", "request": "launch", "stopOnEntry": true, "cwd": "${fileDirname}", "startupClass": "${fileBasename}", "options": [ "-classpath", "${fileDirname}" ] }, { "name": "Java Console App", "type": "java", "request": "launch", "stopOnEntry": true, "cwd": "${fileDirname}", "startupClass": "${fileBasename}", "options": [ "-classpath", "${fileDirname}" ], "externalConsole": true } ] }
The classpath can be set manually in the classpath configuration page. You can open it by executing the Java: Configure Classpath command from the Command Palette (Ctrl+Shift+P).
Just simply move the . java file into src folder and . class file into bin folder and the problem is solved.
I know this is an old question, but anyone who stumbles here and needs a quick and easy fix may find it here. Install the extension: Eclipse New Java Project.
It emulates the behavior of the Eclipse action create Java Project and should produce the results you need.
Just press Ctrl + Shift + P
and type New Java Project (it will pop up after a few letters) and follow the simple directions. (it just asks for the name of the project).
It will create the project and files needed and you won't have to worry about that classpath error. Then just create your class files as normal in the src
folder of your new project and proceed with your programming!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With