classpath - Java: Adding included Jar files to a created Jar file in linux -
i need including imported jar files java program in linux. here program:
import java.sql.*; public class createcoffees { public static void main(string args[]) { try { class.forname("com.ibm.db2.jcc.db2driver"); } catch(java.lang.classnotfoundexception e) { system.err.print("classnotfoundexception: "); system.err.println(e.getmessage()); system.exit(1); } } }
in order execute class.forname("com.ibm.db2.jcc.db2driver");
need 2 .jar
files added classpath:
db2jcc_license_cu.jar db2jcc4.jar
i put these jar files same directory createcoffees.java file, compile , run this:
javac createcoffees.java java createcoffees
but got error
classnotfoundexception: com.ibm.db2.jcc.db2driver
then tried "-classpath" option
javac -classpath ./db2jcc_license_cu.jar:./db2jcc4.jar createcoffees.java java -classpath ./db2jcc_license_cu.jar:./db2jcc4.jar createcoffees
but got this
exception in thread "main" java.lang.noclassdeffounderror: createcoffees caused by: java.lang.classnotfoundexception: createcoffees
how include jar files runnable jar can run java -jar myjar.jar
?
try this
java -classpath ./db2jcc_license_cu.jar:./db2jcc4.jar:. createcoffees
when use -classpath
looses current directory classpath needs .
in classpath explicitly
Comments
Post a Comment