Is this a JRE bug ? Request help

D

Daku

Could some Java guru please help ? I am using :
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)
on a Redhat 2.6.9_34 machine. I am using Eclipse Galileo IDE.
I have downloaded a jar file for use with a simple application that I
am writing, and I can easily set the classpath during compilation and
the application complies perfectly.
I try to invoke my application as:
java FTPTest -classpath
/root/downloads/simpleftp.jar

I am getting an error message as :
Exception in thread "main" java.lang.NoClassDefFoundError: org/jibble/
simpleftp/SimpleFTP
at FTPTest.test(FTPTest.java:16)
at FTPTest.main(FTPTest.java:49)
Caused by: java.lang.ClassNotFoundException:
org.jibble.simpleftp.SimpleFTP

Using the built-in Archive Manager tool, I find that the jar file
contains the correct Java class file.
I am clueless, any hints, suggestions would be invaluable - thanks in
advance for your help.
 
R

Robert Klemme

Could some Java guru please help ? I am using :
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)
on a Redhat 2.6.9_34 machine. I am using Eclipse Galileo IDE.
I have downloaded a jar file for use with a simple application that I
am writing, and I can easily set the classpath during compilation and
the application complies perfectly.
I try to invoke my application as:
java FTPTest -classpath
/root/downloads/simpleftp.jar

I am getting an error message as :
Exception in thread "main" java.lang.NoClassDefFoundError: org/jibble/
simpleftp/SimpleFTP
at FTPTest.test(FTPTest.java:16)
at FTPTest.main(FTPTest.java:49)
Caused by: java.lang.ClassNotFoundException:
org.jibble.simpleftp.SimpleFTP

Using the built-in Archive Manager tool, I find that the jar file
contains the correct Java class file.
I am clueless, any hints, suggestions would be invaluable - thanks in
advance for your help.

You got argument order wrong:

robert@fussel:~$ java -help
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
....
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
....

Cheers

robert
 
M

markspace

Daku said:
I try to invoke my application as:
java FTPTest -classpath
/root/downloads/simpleftp.jar

I am getting an error message as :
Exception in thread "main" java.lang.NoClassDefFoundError: org/jibble/
simpleftp/SimpleFTP
at FTPTest.test(FTPTest.java:16)
at FTPTest.main(FTPTest.java:49)
Caused by: java.lang.ClassNotFoundException:
org.jibble.simpleftp.SimpleFTP


Besides order of arguments to the "java" command, you have to specify
the proper class name for a class file. Something like:

java -cp /root/downloads/simpleftp.jar my.package.FTPTest

In other words, you may have to specify the full name of FTPTest, if
it's not in the default package (i.e., no package).

Hint: specifying the location of FTPTest in the class path too will help.
 
L

Lew

Robert said:
You got argument order wrong:

robert@fussel:~$ java -help
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
...
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
...

Any classpath option provided to the "java" command is ignored if the "-jar"
option is used.
 
R

Robert Klemme

Robert said:
You got argument order wrong:

robert@fussel:~$ java -help
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
...
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
...

Any classpath option provided to the "java" command is ignored if the
"-jar" option is used.

That's true but as far as I can see option "-jar" was not used in this
case (see my quote of the command line above taken from the original
posting).

Cheers

robert
 
L

Lew

Robert said:
You got argument order wrong:

robert@fussel:~$ java -help
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
...
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A : separated list of directories, JAR archives,
and ZIP archives to search for class files.
...
Any classpath option provided to the "java" command is ignored if the
"-jar" option is used.

Robert said:
That's true but as far as I can see option "-jar" was not used in this
case (see my quote of the command line above taken from the original
posting).

The "-jar" was shown in your reply in the context of advice that the the
"-classpath" options apply. Your reply could have misled someone into
thinking that the two options were compatible. I was clarifying that despite
the apparent applicability of "-cp" to a "java -jar" invocation implied by
what you said, it isn't so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top