so I am having a noob moment here, I haven’t ever used the command line to run a java program before but I need to right now. The problem I am having is that when I try to run the program I get a ClassNotFoundException. My class is called OmadUpdate. I already have compiled the OmadUpdate.java file into OmadUpdate.class using the javac command. I have checked the directory and they are both definitely there, however when I run the java OmadUpdate command, it gives me an error message saying
Exception in thread "main" java.lang.NoClassDefFoundError: OmadUpdate (wrong name: org/openmetadata/main/OmadUpdate)
......
......
Could not find the main class: OmadUpdate. Program will exit
But its right there in the directory. When I type dir I have both OmadUpdate.class and OmadUpdate.java. I have even tried using “java org.openmetadata.main.OmadUpdate” because that is the package name that it is under. I am stumped. Thanks for the assistance.
Your class appears to have been declared in the
org.openmetadata.mainpackage.To get java to load the class correctly, it needs to be in the correct directory structure that matches the package structure.
So the classfiles for
org.openmetadata.main.OmadUpdateshould be in the directoryorg\openmetadata\main.Then, when you run the
javacommand, the root of this directory structure should be on the classpath – for a simple example this just means that your current directory should be the parent directory oforg\openmetadata\main.When running
javayou need to specify the full classname using periods not slashes, i.e.