简体   繁体   English

使用Mac OS上的java程序设置mysql.jar的类路径的问题

[英]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. 我有一个java程序,我想在Mac OS上运行。

I have problem in setting classpath of jre and mysql.jar. 我在设置jre和mysql.jar的类路径时遇到问题。

If I set classpath for 'mysql-connector-1.15.0-bin.jar', its displaying exception of 'undefined method - main' 如果我为'mysql-connector-1.15.0-bin.jar'设置类路径,则显示'undefined method-main'的异常

and if I set classpath for 'jre', its displaying 'ClassNotFoundException - com.mysql.jdbc.Driver' . 如果我为'jre'设置classpath,它会显示'ClassNotFoundException - com.mysql.jdbc.Driver'。

Please help how to set both classpath at a time. 请帮助一次设置两个类路径。

classpath has to all the .class files that your application needs, including the ones you write. classpath必须包含应用程序所需的所有.class文件,包括您编写的文件。 Put the MySQL JDBC JAR and the path to your main class into classpath using the -classpath option on javac.exe and java.exe. 使用javac.exe和java.exe上的-classpath选项将MySQL JDBC JAR和主类的路径放入classpath。

You can also specify the classpath in your JAR's manifest . 您还可以在JAR的清单中指定类路径。 It should work on Mac OS or Windows. 它应该适用于Mac OS或Windows。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM