What I'm trying to do is running a .java
source by compiling and running it from command prompt (not using any IDE) using commands javac
and java
and the program connects with MySQL, so everytime I run the program from cmd, I need to specify path of the MySQL connector using -classpath
switch of java
. And entire command to run the program gets something like below:
java -class .;path/to/connector/mysql-connector.jar MySQLConnect
where I want it to be as simple as for other programs like java MySQLConnect
and it should run the program.
Is there any way I can add the connector's path to environment variables of Windows that java
make use of it. I already tried by creating a new CLASSPATH
variable in Windows environment variables and added absolute path of the connector with file name along, but that didn't worked.
Please provide me the workaround of this Windows and Ubuntu as well.
Thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…