• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ClassNotFoundException

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hubert Pernegger
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no, I'm not using a gnu environment....
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that's are a lot of jar files....
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I have done that as you proposed....but I still get the same error:

shell script:
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok,
now I get the this error:

 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, all on one line.
 
Hubert Pernegger
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok,
it was in one line...
I just guess there is something missing in the environment....
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic