• 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

Jars not recognizing in unix

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I have the following batch file in NT
C:
cd C:\Neti\JavaProgs\062806\FlieWatch
java -cp %CD%;%CD%\lib\j2ee.jar;%CD%\lib\mail.jar;%CD%\lib\log4j-1.2.13.jar;%CD%\lib\commons-logging-1.1.jar; FileAlert DEV

pause

The application now needs to be moved to solaris environment. So I changed the batch file to shell script as follows

for name in /home/ln52701/FileWatcher/lib/*.jar ; do
CP=$CP:$name
done
CP=$CP:/home/ln52701/FileWatcher/lib/FA.jar
java -cp $CP FileAlert DEV 2>/home/ln52701/FileWatcher/lib/log.err 1>/home/ln52701/FileWatcher/lib/log.out

When I run the script I am getting the following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Category
~
~

I beleive the script file is not recognizing the jars properly...

I tried to compile the source files individually

$ javac -classpath /home/ln52701/FileWatcher/source/lib/log4j-1.2.13.jar ApplicationProperties.java
ApplicationProperties.java:10: cannot resolve symbol
symbol : class Logger
location: package log4j
import org.apache.log4j.Logger;
^
ApplicationProperties.java:22: cannot resolve symbol
symbol : class Logger
location: class ApplicationProperties
private static Logger log;
^
2 errors
$

Am I giving wrong path or where its going wrong....

Thanks In advance for help

Sridhar
 
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, in the last example, you'd want to try

ls -l /home/ln52701/FileWatcher/source/lib/log4j-1.2.13.jar

to make sure the jar was really there, was of non-zero length, and was readable by you.

In your shell script, I'd want to add

echo $CP

right before you run java.
 
Leela Sridhar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello

I added the ls and echo please find below the output and error messages

$ ksh FA.sh
ls -l /home/ln52701/FileWatcher/source/lib/log4j-1.2.13.jar
:/home/ln52701/FileWatcher/lib/FA.jar:/home/ln52701/FileWatcher/lib/commons-logging-1.1.jar:/home/ln52701/FileWatcher/lib/j2ee.jar:/hom
e/ln52701/FileWatcher/lib/log4j-1.2.13.jar:/home/ln52701/FileWatcher/lib/mail.jar:/home/ln52701/FileWatcher/lib/FA.jar
$

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Category


I changed the permission chmod 777 log4j-1.2.13.jar

infact all jar files

Sridhar
 
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 said "echo ls -l /home/ln52701/FileWatcher/source/lib/log4j-1.2.13.jar", rather than executing the actual ls command; we want to run ls to make sure that file is actually where you think it is.
 
Leela Sridhar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I run the command

$ ls -l /home/ln52701/FileWatcher/source/lib/log4j-1.2.13.jar
-rwxr-xr-x 1 ln52701 misc 358172 Jul 27 12:31 /home/ln52701/FileWatcher/source/lib/log4j-1.2.13.jar

$

Sridhar
 
Leela Sridhar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey

I found out the problem..the problem is the jar files got corrupted...I tried to look into jar files using the command jar tf <jar-filename> it throws an error...if the jar file is not corrupted then it will list of all the file names.

I updated the correct jar files and everything worked...

I hope it could be one of the points when problems like ClassNotFound Exceptions come just look into jar file...who knows
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic