Here's my goal: Use SableCC to generate several parsers/lexers at runtime and load instances of them for parsing and lexing.
So I figured my steps would be:
Generate the
.javafiles using SableCC. I think I've done this, fine.Compile the
.javafile to.classfiles. I did this usingJavaCompiler. I think this worked fine, as well.Put the generated files in a
.jarfile, preserving the file structure. I did this using this as a template. Examining the.jarfile using JarBrowser showed that the file structure of the packages was preserved. Using it, the Jar Catalog looks the same as a regular.jarfile. However, using JarBrowser, my jar doesn't show up under "CLASSPATH catalog." This leads me to believe that my.jarfile isn't being created correctly.Load the
.jarfile into an instance ofURLClassLoader. I'm trying to load it usingClass.forName()but it doesn't seem to be working.
Whenever I do step 4., I get a java.lang.ClassNotFoundException. Does anyone have any ideas as to why this is?
It turns out that I had a slash as a prefix to the file/directory names. I was truncating the parent directory from the file name, but didn't take into account the trailing slash from the parent directory, so
/dir1/file1was being done instead ofdir1/file1. I guessJARfiles are picky.