Problem installing mysql.jar classpath with java program on Mac os

I have a java program that I want to run on Mac os.

I have a problem setting classpath for jre and mysql.jar.

If I set the classpath for 'mysql-connector-1.15.0-bin.jar', its display exception is 'undefined method - main'

and if I set the classpath to 'jre', its display is "ClassNotFoundException - com.mysql.jdbc.Driver".

Please help how to set both class paths at a time.

+4
source share
2 answers

The classpath has all the .class files that your application needs, including the ones you write. Put the JDBC JAR and the path to your main class in the class path using the -classpath option on javac.exe and java.exe.

+2
source

You can also specify the class path in the JAR manifest. It should work on Mac OS or Windows.

  Class-Path: mysql-connector-1.15.0-bin.jar
 Main-Class: your.Program
+2
source

Source: https://habr.com/ru/post/1343579/


All Articles