File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Error message executing shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Error message executing shell script" Watch "Error message executing shell script" New topic
Author

Error message executing shell script

ajay yaduwanshi
Greenhorn

Joined: Oct 12, 2007
Posts: 28
Hi All,
When I am trying to execute the below shell script I got this error message.
script
==========
#!/bin/bash
/usr/java/jdk1.5.0_10/bin/java - classpath /var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar/:
/var/lib/asterisk/agi-bin/jarfiles:
/var/lib/asterisk/agi-bin/800PBXMAIN.jar: com pbx main PBXMain $1 $2 $3 $4 $5 $6 $7

Error
=======

Unrecognized option: -
Could not create the Java virtual machine.
./800PBXMAIN.sh: line 3: /var/lib/asterisk/agi-bin/jarfiles:: No such file or directory
./800PBXMAIN.sh: line 4: /var/lib/asterisk/agi-bin/800PBXMAIN.jar:: No such file or directory


The jarfiles directory and 800PBXMAIN.jar file are in their respective directories.


Thanks & Regards

Ajay Singh Yaduwanshi
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14103
    
  16

/usr/java/jdk1.5.0_10/bin/java - classpath ...

Note the space between "-" and "classpath". That space should not be there. Change this to:

/usr/java/jdk1.5.0_10/bin/java -classpath ...


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
ajay yaduwanshi
Greenhorn

Joined: Oct 12, 2007
Posts: 28
Hi,
Thanks for your reply, however I am still getting no such file and directory error message, although the file(800PBXMAIN.jar) and directory (jarfiles) is present in the given directory, I also change the modes of files to RWX.

Thanks & Regards

Ajay Singh Yaduwanhsi
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3446
    
  12
Originally posted by ajay yaduwanshi:

/usr/java/jdk1.5.0_10/bin/java - classpath /var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar/:
/var/lib/asterisk/agi-bin/jarfiles:
/var/lib/asterisk/agi-bin/800PBXMAIN.jar: com pbx main PBXMain $1 $2 $3 $4 $5 $6 $7


The error message suggests taht these are three separate lines in your script file. If so, they shouldn't be. They are all part of the same command and should be on the same line.
I think you will also find that
com pbx main PBXMain
should actually be
com.pbx.main.PBXMain


Joanne
ajay yaduwanshi
Greenhorn

Joined: Oct 12, 2007
Posts: 28
Hi,
Thanks a lot for your advice and suggestion, I am now getting Exception in thread "main" java.lang.NoClassDefFoundError: com/pbx/main
while executing the script , this is the only error I am getting now.

Thanks & Regards

Ajay Singh Yaduwanshi
[ October 25, 2007: Message edited by: ajay yaduwanshi ]
ajay yaduwanshi
Greenhorn

Joined: Oct 12, 2007
Posts: 28
Hi All,
The above classdef not found error got eliminated Since I have not put dot after com.pbx.main.PBXMain, However I am getting the below error.
java.lang.ClassNotFoundException: com.pbx.PBX800Sample
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at com.pbx.main.PBXMain.main(PBXMain.java:100)

Let me explain you in brief what I did actually, I have created a jar file named 800PBXMAIN.jar containing the PBXMain class which is having a main method and also the jar file is having property file in which I define the path another jar file name PBX800Sample.jar which is being called by our main program, the path set in the property file is like 800PBXMAIN(Key)=/var/lib/asterisk/agi-bin/jarfiles, IN the jarfiles folder I kept PBX800Sample.jar.
My reformated code is

#!/bin/bash
/usr/java/jdk1.5.0_10/bin/java -classpath /var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar:/var/lib/asterisk/agi-bin/jarfiles:/var/lib/asterisk/agi-bin/800PBXMAIN.jar: com.pbx.main.PBXMain $1 $2 $3 $4 $5 $6 $7

Please help me get out of this issue.

Thanks & Regards

Ajay Singh Yaduwanshi
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3446
    
  12
Why can't you just add PBX800Sample.jar to your class path ?
ajay yaduwanshi
Greenhorn

Joined: Oct 12, 2007
Posts: 28
Hi,
Thanks a lot for your suggestion its working. I am really grateful to you for helping me.

Thanks again for the same, May I have your personal mail Id,

Thanks & Regards

Ajay Singh Yaduwanshi
Arthur Buliva
Ranch Hand

Joined: Mar 08, 2006
Posts: 101
And also, next time, export or declare your classpath as

/var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar

and not

/var/lib/asterisk/agi-bin/mysql-connector-java-3.0.15-ga-bin.jar/

which is a different file.

Note the / at the very end
ajay yaduwanshi
Greenhorn

Joined: Oct 12, 2007
Posts: 28
I will definetly follow your advice .
Once again thanks a lot
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3446
    
  12
Originally posted by ajay yaduwanshi:
May I have your personal mail Id


No. These forums are about sharing knowledge, so if you have any more questions feel free to post them on here and then everyone can benefit from the answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error message executing shell script