How to run jvm with extern jar file?

Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.cj.jdbc.Driver

import java.sql.DriverManager;

    class Main {

        static function main() {

            trace("Hello, world!");

            java.lang.Class.forName("com.mysql.cj.jdbc.Driver");//or "com.mysql.jdbc.Driver"

            

        }

    }

build.hxml

-cp src

-D analyzer-optimize

-main Main

--jvm bin/main.jar

--debug

--java-lib lib/mysql-connector-java-5.1.38.jar

then run this

is there somthing wrong here?

java -jar bin/main.jar

Yes, it’s not enough to specify the library in the HXML (compile time), you also need to pass it to the java command (runtime). And you can’t use java -jar with multiple JARs, so you need to use -cp:

java -cp "bin/main.jar;lib/*" haxe.root.Main

(the separator is : instead of ; if you’re not on Windows)

thanks ,it’s work ,use ;on windows and :on ubuntu.

will you add not to here?