From: Timothy J. H. <tim...@ma...> - 2005-03-31 13:33:40
|
Hi Geoffrey, Luckily this has one has an easy solution. The addClasspathUrl is working fine, the problem was that the class you were interested in had a private constructor... Details below ... > On Mar 31, 2005, at 7:08 AM, Geoffrey Knauth wrote: > >> I'm puzzled. This code works in one app: >> >> > (load "elf/jdbc.scm") >> > (load "elf/classpath.scm") >> > (addClasspathUrl "csvdriver.jar") >> > (DriverManager.registerDriver (jstels.jdbc.csv.CsvDriver.)) >> StelsCSV JDBC Driver 2.1 (Trial version) >> $4 = #null >> >> But this code does not in another: >> >> > (load "elf/classpath.scm") >> > (addClasspathUrl "lava3-printf.jar") >> > com.sharkysoft.printf.Printf >> SchemeException: ERROR: undefined variable >> "com.sharkysoft.printf.Printf" There are two problems with the code that doesn't work: 1) com.sharkysoft.printf.Printf needs a "." after it so that it becomes a javadot constructor 2) this Printf class has a private constructor, so if you want to access the constructor you you need to add a "#" after the "." > tim% java -jar jscheme.jarJScheme 7.2 (3/7/05 2:23 PM) > http://jscheme.sourceforge.net > > (load "elf/classpath.scm") > $1 = #t > > > (addClasspathUrl "lava3-printf.jar") > $2 = #null > > > com.sharkysoft.printf.Printf.# > $3 = {jsint.JavaConstructor com.sharkysoft.printf.Printf[0]} > > > com.sharkysoft.print.Printf. > SchemeException: ERROR: undefined variable > "com.sharkysoft.print.Printf." > at jsint.E.error(E.java:14) > at jsint.E.error(E.java:19) > at > jsint.DynamicVariable.getDynamicValue(DynamicVariable.java:27) > at jsint.Evaluator.execute(Evaluator.java:361) > at jsint.Evaluator.eval(Evaluator.java:283) > at jsint.Evaluator.eval(Evaluator.java:272) > at jsint.Evaluator.readEvalWriteLoop(Evaluator.java:129) > at jsint.Evaluator.runJscheme(Evaluator.java:106) > at jsint.Scheme.runJscheme(Scheme.java:170) > at jsint.Scheme.defaultMain(Scheme.java:134) > at jsint.Scheme.main(Scheme.java:109) > at jscheme.REPL.main(REPL.java:156) > > (exit). > $4 = #t > > [dsl092-074-053:~/Desktop/jschemetest/demo] tim% > You can see that it has a private constructor using the (describe CLASSNAME) procedure ... > > (load "elf/basic.scm") > $3 = #t > > > (describe com.sharkysoft.printf.Printf.class) > class: class com.sharkysoft.printf.Printf > public final class com.sharkysoft.printf.Printf extends > java.lang.Object > HashCode: 6584281 > ClassLoader: sun.misc.Launcher$AppClassLoader@c2391a > Package: package com.sharkysoft.printf > Name: "com.sharkysoft.printf.Printf" > > // Constructors > private Printf() ********* Note the private constructor here!! > > // Fields > // Methods > // from java.lang.Object > public native int hashCode() > public final native Class getClass() > public boolean equals(Object) > public String toString() > protected void finalize() > protected native Object clone() > public final void wait(long, int) > public final native void wait(long) > public final void wait() > private static native void registerNatives() > public final native void notify() > public final native void notifyAll() > > // from com.sharkysoft.printf.Printf > public static int out(String, Object[]) > public static int out(PrintfTemplate, Object[]) > public static int out(String, PrintfData) > public static int out(String) > public static int write(Writer, String, Object[]) > public static int write(Writer, String, PrintfData) > public static int write(Writer, String) > public static int write(Writer, PrintfTemplate, Object[]) > public static String format(String) > public static String format(PrintfTemplate, Object[]) > public static String format(String, Object[]) > public static String format(String, PrintfData) > > $4 = #t Cheers, ---Tim--- >> >> In both cases the .jar file in question is in the same directory as >> the .scm file (for testing). >> >> StelsCSV (trial version) came from: http://www.csv-jdbc.com/ >> Lava3 Printf came from: >> http://sharkysoft.com/software/java/lava3/printf/ >> >> Geoffrey >> -- >> Geoffrey S. Knauth | http://knauth.org/gsk >> >> >> >> ------------------------------------------------------- >> This SF.net email is sponsored by Demarc: >> A global provider of Threat Management Solutions. >> Download our HomeAdmin security software for free today! >> http://www.demarc.com/info/Sentarus/hamr30 >> _______________________________________________ >> Jscheme-user mailing list >> Jsc...@li... >> https://lists.sourceforge.net/lists/listinfo/jscheme-user |