You are viewing a plain text version of this content. The canonical link for it is here.
Posted to regexp-user@jakarta.apache.org by jtnews <jt...@bellatlantic.net> on 2000/06/30 07:41:16 UTC
no class def found when using regexp
I'm having problems. I'm not sure why...if someone can give me a
clue.....
first I built the jar file with
export JAVA_HOME=/usr/java/jdk1.3 && sh build-regexp.sh
Then I compiled the following simple test program....
import org.apache.regexp.*;
class RegexTest {
static void main(String [] args) throws Exception {
int i = 0;
String regex = args[i++];
for (;i < args.length; ++i) {
String string = args[i];
System.out.print("RE(\"" + regex + "\").match(\"" +
string + "\")=");
RE r = new RE(regex);
if (r.match(string))
System.out.println("true");
else
System.out.println("false");
}
}
}
Then I compiled with......
javac -g -O -classpath .:/sw/java/lib/jakarta-regexp-1.1.jar
RegexTest.java
Then I ran with....
export LD_LIBRARY_PATH=.:/sw/gcc/2.95.2/lib && java RegexTest "aa*.*"
"alpha"
and got....
RE("aa*.*").match("alpha")=Exception in thread "main"
java.lang.NoClassDefFoundError: org/apache/regexp/RE
at RegexTest.main(RegexTest.java:11)
Can someone send me a small example?
Thanks.
Re: no class def found when using regexp
Posted by Jim Driscoll <ji...@eng.sun.com>.
jtnews wrote:
>
> Ok, I know what I did wrong, I have to specify both -classpath on the compile line
> AND
> CLASSPATH when I run java. I thought it was one or the other, but you have to do
> both.
Not exactly -
-classpath and CLASSPATH are interchangable (mostly, see the docs for
details). But yeah, you have to always say the classpath, whether
compiling or running the VM.
Jim
Re: no class def found when using regexp
Posted by jtnews <jt...@bellatlantic.net>.
Ok, I know what I did wrong, I have to specify both -classpath on the compile line
AND
CLASSPATH when I run java. I thought it was one or the other, but you have to do
both.
Thanks!
Jon Stevens wrote:
> on 6/29/2000 10:41 PM, "jtnews" <jt...@bellatlantic.net> wrote:
>
> > export LD_LIBRARY_PATH=.:/sw/gcc/2.95.2/lib && java RegexTest "aa*.*" "alpha"
> >
> > and got....
> >
> >
> > RE("aa*.*").match("alpha")=Exception in thread "main"
> > java.lang.NoClassDefFoundError: org/apache/regexp/RE
> > at RegexTest.main(RegexTest.java:11)
> >
> > Can someone send me a small example?
>
> Why are you putting gcc into your LD_LIB_PATH? You need to put the
> jakarta-regexp-1.1.jar into your CLASSPATH.
>
> -jon
Re: no class def found when using regexp
Posted by Jon Stevens <jo...@latchkey.com>.
on 6/30/2000 1:57 AM, "jtnews" <jt...@bellatlantic.net> wrote:
> The LD_LIBRARY_PATH is there to load a shared library from a
> JNI. javac -classpath .... is supposed to take care of the classpath
> issue. I tried CLASSPATH too but that didn't work either.
no. javac just is for compiling. you still need to put your .jar's into your
execution classpath. java doesn't static compile stuff.
-jon
Re: no class def found when using regexp
Posted by jtnews <jt...@bellatlantic.net>.
The LD_LIBRARY_PATH is there to load a shared library from a
JNI. javac -classpath .... is supposed to take care of the classpath
issue. I tried CLASSPATH too but that didn't work either.
Jon Stevens wrote:
> on 6/29/2000 10:41 PM, "jtnews" <jt...@bellatlantic.net> wrote:
>
> > export LD_LIBRARY_PATH=.:/sw/gcc/2.95.2/lib && java RegexTest "aa*.*" "alpha"
> >
> > and got....
> >
> >
> > RE("aa*.*").match("alpha")=Exception in thread "main"
> > java.lang.NoClassDefFoundError: org/apache/regexp/RE
> > at RegexTest.main(RegexTest.java:11)
> >
> > Can someone send me a small example?
>
> Why are you putting gcc into your LD_LIB_PATH? You need to put the
> jakarta-regexp-1.1.jar into your CLASSPATH.
>
> -jon
Re: no class def found when using regexp
Posted by Jon Stevens <jo...@latchkey.com>.
on 6/29/2000 10:41 PM, "jtnews" <jt...@bellatlantic.net> wrote:
> export LD_LIBRARY_PATH=.:/sw/gcc/2.95.2/lib && java RegexTest "aa*.*" "alpha"
>
> and got....
>
>
> RE("aa*.*").match("alpha")=Exception in thread "main"
> java.lang.NoClassDefFoundError: org/apache/regexp/RE
> at RegexTest.main(RegexTest.java:11)
>
> Can someone send me a small example?
Why are you putting gcc into your LD_LIB_PATH? You need to put the
jakarta-regexp-1.1.jar into your CLASSPATH.
-jon