Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution to the failure of vscode debugging to load classes

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail about the solution that vscode debugging can not load classes. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

What if vscode debugging fails to load classes?

Visual studio code debug java error: main class cannot be found or cannot be loaded

Javavisual-studio-code

Such as the title:

Use the two java plug-ins on the official website to build an environment for java development and debugging. The configuration file for debugging is as follows:

{/ / use IntelliSense to learn about the relevant properties. / / hover to see a description of an existing property. / / for more information Please visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [{"type": "java", "name": "Debug (Launch)", "request": "launch", "mainClass": "JavaTester", "args": ""} " {"type": "java", "name": "Debug (Attach)", "request": "attach", "hostName": "localhost", "port": 0}]}

Errors are reported all the time when debugging: the error of the main class JavaTester cannot be found or cannot be loaded.

Java.home confirms that the configuration is correct, the environment variables of PC are configured, the classpath is configured as required, and the local terminal debugging is also passed. The main class has not been found here, is there a problem with the configuration of mainClass? Is there any requirement for this configuration?

I just want to simply do some demo-type java development, that is, only run a single java file.

Solution:

Launch.json add configuration classPaths

{"type": "java", "name": "Debug (Launch)", "request": "launch", "classPaths": ["(the class path compiled by your vscode, usually traget/classes)"], "mainClass": "JavaTester", "args": ""}

PS: how do I compile and generate class automatically?

The eclipse method is generally used by default, that is, the .classpath file in the project directory.

How to configure this file, please make your own Baidu.

On the "vscode debugging can not load class solutions" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report