LinuxQuestions.org
Help answer threads with 0 replies.
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 10-15-2002, 08:14 PM   #1
TomCruise2002
LQ Newbie
 
Registered: Sep 2002
Posts: 12

Rep: Reputation: 0
Unhappy Running Java Socket Program in a shell during bootup


I have a server program written in Java. When started the program needs to run in a loop to keep listening for clients to connect.

I want to have this program running when the user boots up the PC and Linux is running in runlevel 5. What should happen is that the server program runs in a bash shell within the desktop.

I tried placing the command line [which in my case is java myserver] in the .bashrc script file in the user's directory. Of course all the paths and classpaths for JRE have been set before this line.

What happens, however, is that when I bootup, the blue desktop in X11 appears and hangs there. The other desktop components do not appear. Apparently what has happened is that Linux is in X11, the .bashrc script has run, and because my program is running, the other desktop components in Gnome cannot execute. I know my program is running when I take a look at the processes running from another terminal.

When I switch to runlevel 3, during bootup, my program runs (in command line mode, it shows 'Myserver is running in <ip> at <port>), and everything stops there.

So, how do I boot up in graphical mode and haev my server program running in a separate shell at the end.

Please help

Anthony
 
Old 10-15-2002, 10:28 PM   #2
bah
Member
 
Registered: Apr 2001
Posts: 38

Rep: Reputation: 15
OK... to run the program first of all you need to put it in the background. This means put an ampersand (ie &) at the end of your command line ("java myserver &"). You potentially need to pipe output from the command to a log file or to /dev/null.
Secondly: If you want this program to be run when your computer is started, you need to have it executed in the appropriate "rc" scripts. How you do this depends on the distro you are running, and I would DEFINITELY make sure I had the script working properly before making it part of your system bootup, as you could easily hang your system.
What I would do is seperate out the PATH statements, LD_LIBRARY_PATH, etc and the command line you need to run the java program into a shell script, and test that shell script thoroughly. Log in as root at run level 3 and make sure root can run the script. Background the script and make sure your program runs properly.
Once you have tested all these things, put a call to your shell script in your rc.local file (or equivillent) MAKING SURE YOU BACKGROUND IT!!! ie Make sure you have the ampersand at the end of the line.

Also think about the security implications of having your own networked server running.

Last edited by bah; 10-15-2002 at 10:31 PM.
 
  


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
Running shell script within a C or C++ program Quantum0726 Programming 2 06-15-2005 09:14 PM
Running shell scripts from Java cmpich Programming 1 04-19-2005 04:36 AM
running a program from shell script Suinatsa Programming 10 04-14-2005 11:25 AM
running shell scripts using Java niravk8 Programming 2 02-09-2005 09:42 AM
running SHell script from java anirudh Programming 2 01-07-2005 07:37 AM


All times are GMT -5. The time now is 02:46 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