[java] I keep getting ClassNotFoundException...

Asked 2 years ago, Updated 2 years ago, 149 views

Hello, I'm coding through eclipse with java... My own object (specifically MyButton) is defined and used in code, as shown in the picture.The following error states that class cannot be found even though java exists. Can you help me with how to solve it?

java.lang.ClassNotFoundException: MyButton
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351).....

java classnotfoundexception

2022-09-20 22:03

1 Answers

Did an exception occur when calling URLClassLoader.findClass()? If you put "MyButton" as a factor, please put the full name including the package name.

I created a resource folder inside the project and made MyButton to be called as a .dat extension file: fileIn=newFileInputStream("resources/data/RRM.dat"); objIn=newObjectInputStream(fileIn); I have a lot of room for improvement, so I don't understand What do you mean by full name including package name?

It must be caused by the failure to find the class in the process of de-serialization. Are the codes you mentioned and the MyButton classes in different projects?

I don't think so, but did the package name of the MyButton class change when you created RRM.dat?


2022-09-20 22:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.