[Java] Java Compiling & Execution in Shell

[Java] Java Compiling & Execution in Shell
0 votes, 0.00 avg. rating (0% score)

I just created this DB transfering class from Oracle to Mysql and tried to run it under linux, but had hard time to compile & run it.

But I successfully did it. And the code works fine too.


javac -classpath /var/www/java_libs/mysql-connector-java-3.1.7-bin.jar:/var/www/java_libs/v9_ojdbc14.jar:/var/www/import importdb/Import.java

java -classpath /var/www/java_libs/mysql-connector-java-3.1.7-bin.jar:/var/www/java_libs/v9_ojdbc14.jar:/var/www/import importdb/Import

The main class is Import and it is a part of package ImportDB.

/var/www/java_libs/mysql-connector-java-3.1.7-bin.jar : MySQL lib downloaded from MySQL website

/var/www/java_libs/v9_ojdbc14.jar : Oracle Lib downloaded from Oracle website

Note that the /var/www/import in the classpath. This is where importdb folder is located. It is necessary. Without it, you will get Exception in thread “main” java.lang.NoClassDefFoundError: importdb/Import.

Leave a Reply

Your email address will not be published. Required fields are marked *