Gagan
Gagan

Reputation: 129

Problem on setting classpath of mysql.jar with java program on Mac os

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

I have problem in setting classpath of jre and mysql.jar.

If I set classpath for 'mysql-connector-1.15.0-bin.jar', its displaying exception of 'undefined method - main'

and if I set classpath for 'jre', its displaying 'ClassNotFoundException - com.mysql.jdbc.Driver' .

Please help how to set both classpath at a time.

Upvotes: 4

Views: 857

Answers (2)

trashgod
trashgod

Reputation: 205785

You can also specify the classpath in your JAR's manifest. It should work on Mac OS or Windows.

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

Upvotes: 2

duffymo
duffymo

Reputation: 308753

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

Upvotes: 2

Related Questions