There is a jar file already deployed and successfully running. And now we need to add a very small string in a class.
These are the steps so far i made:
1.) I already decompile/extract the jar into a folder.
2.) Open a class file in JDgui(java file viewer).
3.) Copy the source code in notepad++ and save as fileName.java
4.) Compile that .java as .class via cmd.
5.) Compile the folder again as .jar file (the same as the old .jar which is running)
Now when i restarted Tomcat, run the system, then it showing the error:
ClassNotFoundException
When i open that jar file in JDGui the class is in it.
Please help. Thanks
This is no doubt coming from the error you naming the class differently or placing it in a different package (different folder).
When you save source of the class in a Java file, make sure you save it in a folder that reflects its package, and also place the package
statement at the beginning of the file, reflecting the folder structure properly.
Also note that if the class is declared as public
, it must be in a file named after the class: ClassName.java
else it won't even compile. So you saving it in filename.java
will not work in this case.
Also make sure you get no comile errors when you recompile this java file after modifying it (else you will not get a result .class
file).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.