aspose file tools*
The moose likes Java in General and the fly likes ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "ClassNotFoundException" Watch "ClassNotFoundException" New topic
Author

ClassNotFoundException

Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi,
my java environment is working properly, but nevertheless I got that error:



the program compile without problems in eclipse, then I invoke a shell script that uses the above mentioned WSMPsrchClient, when I perform the shell script I get that error.

thanks for help

[ EJFH: Added newlines in long classpath to fix page formatting ]
[ May 15, 2006: Message edited by: Ernest Friedman-Hill ]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14351
    
  22

Are you using a GNU Java environment?

Your system cannot find the class named WSMPsrchClient, most likely because you didn't include the directory or JAR file that contains it in the classpath.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Ramen Chatterjee
Ranch Hand

Joined: Apr 27, 2006
Posts: 62
Just to add to Jesper's comment - check your project properties in Eclipse and see what jars are in your project that are missing when you run your script. Also, you could try printing the value of CLASSPATH from your script to check the paths/jars.

Regards

Ramen


Could try harder
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Also carefully check the shell script against the actual name of the class, because you may simply have misspelled it. Finally, the shell script uses an unqualified name for the class, but perhaps it is (as all classes should be) defined in a package, and you've left the package name off.


[Jess in Action][AskingGoodQuestions]
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi,
I have added the missing jar files to my project, and checked names, but I still get the same error....

my classpath evironment:
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
no, I'm not using a gnu environment....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Well, this is the first time you're mentioning Tomcat, so of course that makes a difference -- is this a Web application? If so, the answers are going to be totally different, so let us know.

If it's not a Web application, then your CLASSPATH is quite wrong, far worse than just the default setting you'd get if CLASSPATH were entirely unset. You're telling Java that the only classes of interest will come from those two jars included in the JDK, which is surely not at all what you intend.

Anyway, let us know abot the Web application thing and we'll help you work this out.
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
no, sorry,
this program is not a web application....

ups, does that mean I have to add in the classpath all the jar files that are included in the project as well....
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
that's are a lot of jar files....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Hubert Pernegger:
no, I'm not using a gnu environment....


It was a kind of rhetorical question: the known answer to which is "yes, you surely are." Whether you know it or not, rather than using the Sun JVM, you're using the GNU "gcj" toolchain: hence the "gnu.gcj.runtime.SystemClassLoader" in the error message.
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
ok, sorry, thanks for the explanation....

but do I have to add all the jar files from the project also into the classpath....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Again, you need to tell us first if this is a Web application or not -- it matters tremendously. But honestly, the answer is "no" -- even if it's not a Web application, there are other better ways than setting CLASSPATH.
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
no it is not a webapplication....
it is a usual java application, that I invoke within a shell script with a few parameters....
and in eclipse I can compile it without any problems.....

but the shell script doesn't work (error mentioned in the first post)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

OK, cool, we're in the home stretch, then.

Right now you've got something like

java WSMPsrchClient

just edit the script so be something like

java -classpath /usr/wherever/jar1.jar:/usr/someplace/jar2.jar:/usr/another/jar3.jar

where jar1.jar, jar2.jar, etc, are all the jars your application needs. This is assuming everything is in a jar, of course; otherwise there's a sometimes confusing way of adding directories where classes may be found.

The -classpath switch overrides the environment variable.
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi,
I have done that as you proposed....but I still get the same error:

shell script:
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

You've got two different "java" lines there. You want to put that -classpath switch, with its long argument, on the second java command line (removing the first altogether.) Put it before the name of the class -- i.e.,

java -classpath /home/...:/home... WSMPsrchClient --matrix BLOSUM70 ...
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
ok,
now I get the this error:

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Looks like you've got lots of extra newlines in there, breaking up the classpath. Please tell me you didn't do that because of the edit I did to your first post -- that was just so the formatting of this forum page wasn't all messed up by one enormous long line.
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi,
what do you mean...
it is all in one line java --classpath ......WSMPsrchClient.....

or what exactly do you mean....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Yes, all on one line.
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
ok,
it was in one line...
I just guess there is something missing in the environment....
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by Hubert Pernegger:
ok,
it was in one line...
I just guess there is something missing in the environment....


The error messages you recieved very clearly indicated that it was spread across multiple lines. Do you have this working yet?
Hubert Pernegger
Ranch Hand

Joined: Apr 11, 2006
Posts: 49
hi,
ok I have put all in one line and I get the same error again that I have posted in the first post.

ok it seems I have both installed: /usr/java/jre1.5.0
and /usr/lib/jvm/java-1.4.1-gcj

in eclipse I'm using the jre1.5.0, but on the command line it seems that it is looking in /usr/lib/jvm/java-1.4.1-gcj
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ClassNotFoundException