Class.forName?

Jim Laskey (Oracle) james.laskey at oracle.com
Fri Jan 31 17:20:53 PST 2014


Since I don't have the jar handy, I'm just guessing, but why wouldn't you just;

jjs> var driverClass = Java.type("org.apache.derby.jdbc.ClientDriver");

-- Jim

On Jan 31, 2014, at 7:43 PM, Tom McGinn <tom.mcginn at oracle.com> wrote:

> Hello -
> 
> I am trying to create a JS file that illustrates using Java classes mixed with JS.
> 
> I am trying to connect to the sample JavaDB instance, but am not able to load the driver class.
> 
> jjs -cp /home/tmcginn/jdk1.8.0/db/lib/derbyclient.jar
> jjs> var driver = "org.apache.derby.jdbc.ClientDriver";
> jjs> Java.type("java.lang.Class").forName(driver);
> java.lang.RuntimeException: java.lang.ClassNotFoundException: org.apache.derby.jdbc.ClientDriver
> 
> I think I am missing something obvious....
> 
> I am running this on Oracle Linux 6 u3 on an OVM.
> 
> Thanks,
> 
> Tom
> 
> -- 
> 
> 
> Tom McGinn | Java Curriculum Developer
> OracleServer Technologies Curriculum Development
> Phone: +1.781.442.0621
> Mail: tom.mcginn at oracle.com
> Blog: Java Training Beat <https://blogs.oracle.com/javatraining/>
> 



More information about the nashorn-dev mailing list