LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-16-2010, 04:10 PM   #1
Dylannnnn
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Rep: Reputation: 0
Problem with my run.sh


Ok, im quite new to linux but have an "ok" knowledge of it.

I am trying to convert my batch file into a .sh file and i think i have it perfect but it just will not work, so obviously not perfect.

This is the code for my batch file.

Code:
@echo off
title Server
java -Xmx800m -cp bin;deps/poi.jar;deps/mysql.jar;deps/mina.jar;deps/slf4j.jar;deps/slf4j-nop.jar;deps/jython.jar;log4j-1.2.15.jar; server.Server
pause
This works perfectly on my own computer without any problems. I want to host this on my Linux VPS (CentOS 5) and need it to be converted into run.sh.

This is the code for my run.sh.

Code:
#!/bin/sh
java -Xmx800m -cp bin;deps\poi.jar;deps\mysql.jar;deps\mina.jar;deps\slf4j.jar;deps\slf4j-nop.jar;deps\jython.jar;log4j-1.2.15.jar; server.Server
sleep
As I have said I don't think anything is wrong with it but obviously there is as it will not run the server. If someone could help me with this it would be very much appreciated.
 
Old 09-16-2010, 05:06 PM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
Well what messages do you get when it runs on the server?

Semicolons can't be the right delimiter on Unix, and if they are, you'll need to quote the input. An unquoted semicolon means "new command."

Instead of "sleep", use "read". "sleep 10" will pause for 10 seconds. "read" will pause and wait for input.
 
Old 09-16-2010, 06:03 PM   #3
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Ok, I've got to ask to cover all the bases. You have execute/run permissions on the script, right?

Secondly, I know nothing about executing java from the command line, but aren't the slashes in the command supposed to be forward slashes ('/')? Those look like references to files. Linux uses forward slashes to handle directory paths and uses backslashes to escape special characters.
 
Old 09-17-2010, 11:41 AM   #4
Dylannnnn
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
this is the error i get when i change the run.sh and edited the "\" to "/"

This is my run.sh file
Code:
#!/bin/sh
java -Xmx800m -cp bin;deps\poi.jar;deps\mysql.jar;deps\mina.jar;deps\slf4j.jar;deps\slf4j-nop.jar;deps\jython.jar;log4j-1.2.15.jar; server.Server
sleep
This is the error i get with it.
Code:
run.sh: line 2: deps/poi.jar: Permission denied
run.sh: line 2: deps/mysql.jar: Permission denied
run.sh: line 2: deps/mina.jar: Permission denied
run.sh: line 2: deps/slf4j.jar: Permission denied
run.sh: line 2: deps/slf4j-nop.jar: Permission denied
run.sh: line 2: deps/jython.jar: Permission denied
run.sh: line 2: log4j-1.2.15.jar: command not found
: command not found
: command not foundver.Server
: command not foundep
this is realllllly annoying me now.

I have chmod +x run.sh

Last edited by Dylannnnn; 09-17-2010 at 11:48 AM.
 
Old 09-17-2010, 12:31 PM   #5
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
So, yes. Semicolons can't be the right delimiter on Unix, and if they are, you'll need to quote the input. An unquoted semicolon means "new command."

Instead of "sleep", use "read". "sleep 10" will pause for 10 seconds. "read" will pause and wait for input.

Aren't the slashes in the command supposed to be forward slashes ('/')? Those look like references to files. Linux uses forward slashes to handle directory paths and uses backslashes to escape special characters.
 
Old 09-17-2010, 12:52 PM   #6
Dylannnnn
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by AlucardZero View Post
So, yes. Semicolons can't be the right delimiter on Unix, and if they are, you'll need to quote the input. An unquoted semicolon means "new command."

Instead of "sleep", use "read". "sleep 10" will pause for 10 seconds. "read" will pause and wait for input.

Aren't the slashes in the command supposed to be forward slashes ('/')? Those look like references to files. Linux uses forward slashes to handle directory paths and uses backslashes to escape special characters.
Ok this is now my run.sh file.

Code:
#!/bin/sh
java -Xmx800m -cp bin:deps/poi.jar:deps/mysql.jar:deps/mina.jar:deps/slf4j.jar:deps/slf4j-nop.jar:deps/jython.jar:log4j-1.2.15.jar server.Server
read 10s
Is this right?

I get an error with this.

Code:
Exception in thread "main" java.lang.NoClassDefFoundError: server/Server
Caused by: java.lang.ClassNotFoundException: server.Server
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:319)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:264)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:332)
. Program will exit.ain class: server.Server

Last edited by Dylannnnn; 09-17-2010 at 12:54 PM.
 
Old 09-17-2010, 07:23 PM   #7
Dylannnnn
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
still looking for help <3
 
Old 09-17-2010, 08:45 PM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Note that the file doesn't have to end with .sh, Linux has no OS or filesystem-level concept of file extensions.
 
Old 09-18-2010, 01:21 AM   #9
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Quote:
Originally Posted by Dylannnnn
Code:
Caused by: java.lang.ClassNotFoundException: server.Server
Your command ends with "server.Server"--which indicates what object serves as the application's starting point. The error above seems to be saying that java can't find an object defined by that name.

So, we really can't help much other than to say the problem is likely in one of two places:
1. The command line is specifying the starting class incorrectly. This might be a result of the fact that Linux is case-sensitive for names, whereas my experience with Windows (which is somewhat dated now) indicates that Windows is NOT case-senstive. Verify how the class is defined in the code you're trying to start.

2. There is one (or more) additional files that are not being loaded/included properly. Double-check your paths for spelling mistakes and double-check your file lists to make sure all needed files are included on the command line.
 
Old 09-18-2010, 07:30 AM   #10
Dylannnnn
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Dark_Helmet View Post
Your command ends with "server.Server"--which indicates what object serves as the application's starting point. The error above seems to be saying that java can't find an object defined by that name.

So, we really can't help much other than to say the problem is likely in one of two places:
1. The command line is specifying the starting class incorrectly. This might be a result of the fact that Linux is case-sensitive for names, whereas my experience with Windows (which is somewhat dated now) indicates that Windows is NOT case-senstive. Verify how the class is defined in the code you're trying to start.

2. There is one (or more) additional files that are not being loaded/included properly. Double-check your paths for spelling mistakes and double-check your file lists to make sure all needed files are included on the command line.
This is my file layout:

The file server has bin src deps data run.sh

the bin file goes like this. bin>server>and the Server.class file is in here.

in the deps folder all the .jar files are in there.

I really do not know why it is not working.. please help :L
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
run command problem ust Linux - Newbie 1 07-09-2008 01:02 AM
problem when I run startx Warmduvet Slackware 5 09-13-2004 10:33 PM
winex run problem mmm Linux - Newbie 1 06-17-2003 02:03 PM
winex run problem mmm Linux - Software 0 06-17-2003 01:54 PM
Run level 4 problem jamaso Slackware 2 04-25-2002 11:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration