Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-12-2004, 04:04 AM
|
#1
|
LQ Newbie
Registered: Oct 2004
Location: Bundoora, Australia
Distribution: Fedora Core 2 on Dell PE700
Posts: 12
Rep:
|
Starting Java from shell script (Exception in thread "main")
I try to run a Java-Class, which resides in a .jar file, from a shell script.
My script (create-tables.sh) looks like the following:
#!/bin/bash
java -cp :acf.0.9.2.4.jar:acf.scheduler.0.9.2.4.jar:um.0.9.2.4.jar:ims.server.0.9.2.4.jar:mySQLjdbc.jar org.managedimages.ims.server.services.installation.CreateTablesX
When I start the script with ./create-tables.sh, the result will be the following:
[root@rm12 installation]# ./create-tables.sh
Exception in thread "main" java.lang.NoClassDefFoundError: org/managedimages/ims/server/services/installation/CreateTablesX
But when I cut&paste the java command into the console, and run
it directly from the console, the class runs through fine...
JAVA_HOME and PATH are set properly. Is there anything missing
in my shell script? Also, I have the same problem with starting ant,
from the script it doesn't work, from the console it works...
Here is additional info:
[root@rm12 installation]# pwd
/var/managedimages/prod/installation
[root@rm12 installation]# echo $JAVA_HOME
/usr/java/j2sdk1.4.2_05
[root@rm12 installation]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/java/j2sdk1.4.2_05/bin:/usr/local/apache-ant-1.6.2/bin:/root:/root/bin
[root@rm12 installation]# ls -al
total 1908
drwxr-xr-x 2 root root 4096 Oct 12 17:37 .
drwxr-xr-x 6 root root 4096 Oct 12 12:41 ..
-rw-r--r-- 1 root root 493087 Oct 12 12:41 acf.0.9.2.4.jar
-rw-r--r-- 1 root root 40247 Oct 12 12:41 acf.scheduler.0.9.2.4.jar
-rw-r--r-- 1 root root 127 Oct 12 12:41 bootstrap.acf.properties
-rw-r--r-- 1 root root 157 Oct 12 12:41 bootstrap.acf.scheduler.properties
-rw-r--r-- 1 root root 218 Oct 12 12:41 bootstrap.ims.server.properties
-rw-r--r-- 1 root root 252 Oct 12 12:41 bootstrap.properties
-rw-r--r-- 1 root root 150 Oct 12 12:41 bootstrap.um.properties
-rw-r--r-- 1 root root 172 Oct 12 12:41 create-root-user.bat
-rwxr-xr-x 1 root root 196 Oct 12 12:57 create-root-user.sh
-rwxr-xr-x 1 root root 197 Oct 12 12:41 create-root-user.sh~
-rw-r--r-- 1 root root 176 Oct 12 12:41 create-tables.0.9.1.bat
-rwxr-xr-x 1 root root 500 Oct 12 16:54 create-tables-1.sh
-rwxr-xr-x 1 root root 599 Oct 12 16:53 create-tables-1.sh~
-rw-r--r-- 1 root root 170 Oct 12 12:41 create-tables.bat
-rw-r--r-- 1 root root 53438 Oct 12 17:00 create-tables.log
-rwxr-xr-x 1 root root 182 Oct 12 17:37 create-tables.sh
-rwxr-xr-x 1 root root 191 Oct 12 17:12 create-tables.sh~
-rw-r--r-- 1 root root 882037 Oct 12 12:41 ims.server.0.9.2.4.jar
-rw-r--r-- 1 root root 287712 Oct 12 12:41 mySQLjdbc.jar
-rw-r--r-- 1 root root 94602 Oct 12 12:41 um.0.9.2.4.jar
[root@rm12 installation]#
|
|
|
10-12-2004, 09:49 AM
|
#2
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994
Rep:
|
What happens if you run the script with this:
Code:
bash ./create-tables.sh
This has to be an environment problem. It could be that the environment isn't being inherited by the script; in which case, check that you own the file. From the bash manpage:
Quote:
If the shell is started with the effective user (group) id not equal to the real user (group) id, and the -p option is not supplied, no startup files are read, shell functions are not inherited from the environment, the SHELLOPTS variable, if it appears in the environment, is ignored, and the effective user id is set to the real user id. If the -p option is supplied at invocation, the startup behavior is the same, but the effective user id is not reset.
|
You could also try adding -p to the shebang line in this case (though I haven't tried this)
(Edit: The shebang line is the one that starts with #!)
|
|
|
10-17-2004, 06:50 PM
|
#3
|
LQ Newbie
Registered: Oct 2004
Location: Bundoora, Australia
Distribution: Fedora Core 2 on Dell PE700
Posts: 12
Original Poster
Rep:
|
Uff, I found out what the problem was...
I created the shell script in Windows using Eclipse.
This was the version which didn't work. Then,
on my Linux box, I played a bit around with the
kedit editor, as I found by accident, that when I
remove the first CR/LF and re-add it in kedit, the
shell script works!
I can remember exactly, but what was the difference
between Win and iX? iX has <CR> only and Win has <CR><LF>?
Or was it vice versa? Anyway, this is funny behavior...
Does anyone know about this?
Last edited by rolf_mueller; 10-17-2004 at 06:51 PM.
|
|
|
10-18-2004, 04:35 AM
|
#4
|
Senior Member
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994
Rep:
|
Windows uses <CR><LF>
UNIX and Linux use <LF> (I think it's LF from cating a file straight to a printer)
I think it's Mac OS that uses <CR> (but it might be the amega or something)
Edit: To a hardware printer, <CR> feed's one line's worth of paper, <LF> moves the head to the beginning of the current line. So you need to send <CR><LF> when printing text.
Last edited by rjlee; 10-18-2004 at 09:10 AM.
|
|
|
10-18-2004, 08:41 AM
|
#5
|
Member
Registered: Apr 2001
Location: Cambridge, England
Distribution: Slackware 10, Fedora Core 3, Mac OS X
Posts: 617
Rep:
|
Macs do indeed use <CR> (though not sure now that Mac OS X has a BSD core).
I'm going by what I read a while ago but I think it comes from old teletype machiens etc. that were sending messages over telephone wires (similar to FAX machines). The <LF> stands for Line Feed and returns the location of the next character down a line. A separate command would return the cursor to the beginning of the line. <CR> on the other hand does both in one sweep. However, when computers where still maturing different operating systems used either one or the other. MS Windows went for including both just to be sure even though it makes little sense.
Please take this with a pinch of salt since I haven't read up on this for a while. Unfortunately this old over throw of the old days of computers still comes up and bites us in the backside. I usually notice it when move a Linux text file to Windows. Windows will just display it as one solid line of text with a little box to denote where the <LF>'s are.
Alex
P.S. Its been a while since I've posted so go easy on me..... :P
|
|
|
10-30-2004, 03:11 AM
|
#6
|
LQ Newbie
Registered: Oct 2004
Location: Bundoora, Australia
Distribution: Fedora Core 2 on Dell PE700
Posts: 12
Original Poster
Rep:
|
The lesson I've learned is, that I create the scripts on the Linux system,
test them there, and then copy them over to my development system (win2k)
and check them in...
|
|
|
All times are GMT -5. The time now is 08:12 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|