I developed a Java Application to run on Mac BigSur. I used Java Derby as database for this application. The Application gives an Exception:

java.lang.ClassNotFoundException:org.apache.derby.jdbc.EmbeddedDriver

The interesting fact is that When I run this application on my MacBigSur(Which I have installed on Virtual Box) then the application runs perfectly. But when I run the application on Physical Mac BigSur, then it gives the above mentioned exception.
I am pasting the code Iused for Creating connection to Database.

String dbdriver = "org.apache.derby.jdbc.EmbeddedDriver";
Class.forName(dbdriver).newInstance();
con = DriverManager.getConnection("jdbc:derby:/users/daniyalumar/4DSOFTECHDB; create = true");

The error message you are getting, java.lang.ClassNotFoundException:org.apache.derby.jdbc.EmbeddedDriver, indicates that the EmbeddedDriver class could not be found. This suggests that the necessary classes for the Apache Derby database may not be on the classpath when the application is run on the physical Mac BigSur.

To fix this issue, you will need to make sure that the Apache Derby classes are on the classpath when running the application. There are a few ways you can do this.

One way is to include the Apache Derby JAR file on the classpath when running the application. For example, you can use the -cp or -classpath option when running the java command to specify the path to the Apache Derby JAR file:

java -cp /path/to/derby.jar MyApplication

Another way is to add the Apache Derby JAR file to the lib directory of the Java installation on your physical Mac BigSur. This will make the Apache Derby classes available on the classpath for all Java applications run on the system.

If you are using a build tool like Maven or Gradle, you can also include the Apache Derby dependency in your project and specify the version of the Apache Derby JAR to use. The build tool will then handle downloading and adding the necessary JAR files to the classpath when building and running the application.

I hope this helps! Let me know if you have any other questions.

commented: I have already added the Derby.jar files in lib folder of my Java Application , despite of this I am facing this issue +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.