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

How to solve the error of Java class

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "how to solve Java class errors". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to solve Java class errors".

Because in tomcat's web application, webapp's own class loader loads the classes in the WEB-INF/classess directory first, and then entrusts the superior class loader to load, if we write a java.lang.String in tomcat's web application, the Servlet program loads our own java.lang.String, but doing so will give rise to a lot of potential problems. It turns out that all those who use the java.lang.String class will have a problem.

Although java provides endorsed technology, you can override some classes in jdk by … . . However, the classes that can be overridden are limited, but they do not include classes in packages such as java.lang.

(for example, the following is mainly for everyone to learn and understand only, not as part of the answer, otherwise, it is suspected that the topic is leaked.) for example, run the following program:

The errors reported are as follows:

Java.lang.NoSuchMethodError: main

Exception in thread "main"

This is because the java.lang.String that comes with jre is loaded, and there is no main method in this class.

At this point, I believe you have a deeper understanding of "how to solve Java class errors". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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

Development

Wechat

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

12
Report