473,387 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Running long java command from solaris shell script

Hi,

I wasn't sure whether this should be posted in the Java are or in a
Solaris thread, so I shall post it in both. Sorry for the
duplication.

I am new to Solaris and am having trouble running a long Java command
from a shell script.

Firstly, my Solaris (8) / Java setup. Mu machine already had Java 1.2
installed in it in /usr/bin, I have now installed 1.4 into a different
directory. My sub users have had their PATH variable changed to
reference the new Java installation, such that 'which java' results in
/new_java_dir/java.

I have a long java command that gets cut off from the command line, in
Windows I have got round this by specifying it in a batch file, so am
trying to do the same in Solaris. The java command contains a single
jvm arg, which specifies the property file to be used. I first of all
tried to run the script using

#!/usr/bin/java

java long_classpath system_props my.class.name myapp.properties

The output from this indicates that the property file cannot be found.
I have ensured that the . (where the file is stored) is in the
classpath, adn also specifying the full path to the file. The same
error occurs where I use #!/bin/sh to run this script. When I try a
noddy, just running a shorter command from the command line, the arg
gets found ok.

When I try to specify my new java installation in the first line, i.e.
/new_java_dir/java I get the this error:
Error: could not find libjava.so
Error: could not find Java 2 Runtime Environment

Any help would be greatly appreciated, I've been struggling with this
all day...

Thanks,
Laura
Jul 17 '05 #1
4 12046
Hi again,

Thanks to an answer I got from the Solaris group I have now tidied up
my installation, and am fairly confident that java is being called
correctly. However, I am still having problems finding the file
specified by my main method arg... If anyone has any idea what I am
doing wrong in my set up below it would be great :)

I have a bin directory, which contains my script and all property
files, it also contains a libs directory which in turn contains the
jars my application needs to run.

My script is like this:
#!/bin/sh
JAVA_HOME=/usr/java
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME

java -version
java -classpath .:./libs/first.jar:./libs/second.jar:./libs/nth.jar
-DLOG_AREA=logs/ -DFTP_BUFFER_SIZE=32768 com.my.main.MainClass
myapp.props

When I run the script the correct java version is printed then I get a
FileNotFound exception for myapp.props (No such file or directory).
The property file is definitely in the directory that the script runs
from. I have also tried using "java <...> ./myapp.props" and "java
<...> /full/path/from/root/myapp.props", both of which give the same
exception. I have tried settin full read/write/exec permissions for
all users on "myapp.props" just to be sure, to no avail, and also
tried creating a jar contining the props file and adding that jar to
the classpath (although I didn't really except that to work as I have
the feeling I would need to change my application code to access the
jar as a resource.)

I have had a very similar setup running in Windows with the same code
and classpath directories, running from a batch file. I can't work
out what is different and wrong about my Solaris setup...

Any ideas??

Thanks in advance,
Laura
Jul 17 '05 #2
Laura,

Please post the code you are using to open the props file. Also, post
the output from the command line when you run the script. To verify the
permissions of the file, please post the output from "ls -l" and
"whoami" as well.

Also, I noticed in your script that you are using relative paths. While
this may or may not be the problem, I believe it to be a poor practice.
The script may be invoked from any directory, which would cause the
paths to be invalid.

Ray

Jul 17 '05 #3
Laura,

Please post the code you are using to open the props file. Also, post
the output from the command line when you run the script. To verify the
permissions of the file, please post the output from "ls -l" and
"whoami" as well.

Also, I noticed in your script that you are using relative paths. While
this may or may not be the problem, I believe it to be a poor practice.
The script may be invoked from any directory, which would cause the
paths to be invalid.

Ray

Jul 17 '05 #4
Thanks, for your suggestions, however I have now found the problem.

I had been using dtpad to view and edit my script,which doesn't show
whitespace characters When I checked the truss report it was trying to
open app.properties^M, which doesn't exist.

Cheers!


Please post the code you are using to open the props file. Also, post
the output from the command line when you run the script. To verify the
permissions of the file, please post the output from "ls -l" and
"whoami" as well.

Also, I noticed in your script that you are using relative paths. While
this may or may not be the problem, I believe it to be a poor practice.
The script may be invoked from any directory, which would cause the
paths to be invalid.

Ray

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Adi | last post by:
A java program we have written crashes with IBM JDK 1.3.1 on linux. It works fine on other platforms(Solaris,HPUx). It gets a SIGSERV Signal 11 and crashes just after few minutes after starting up....
1
by: Hal Vaughan | last post by:
I'm having trouble with a bash script (in Linux) I'm running from Java. It works -- some of the time, but I can't determine exactly why it works 1 time and doesn't work the next 4-5 times. I'm...
9
by: Erik Geiger | last post by:
Hi, sorry, my english ist not that got but I'll try. I have a running python script (capisuit incoming.py). This script shall start a linux shell script. If I start this script like...
0
by: paulhjwu | last post by:
Hi, I have problems running a couple of shell scripts from PHP. I found a similar posting, so I posted my question to the original author. But unfortunately the original author is not at the...
11
by: Gregor Kovač | last post by:
Hi! I have an SQL script with bunch of CREATE TABLES, ALTER TABLES, ... I'd like it to run transactially. I have found that id I run a ALTER STATEMENT inside a transaction and then roll it back...
13
by: wattersmt | last post by:
Hello, I am trying to write a python cgi that calls a script over ssh, the problem is the script takes a very long time to execute so Apache makes the CGI time out and I never see any output. ...
2
by: smitanaik | last post by:
i have a java file which i am running through shell script. the syntax that i have used is #! /bin/bash javac Copy.java
4
by: Propad | last post by:
Hello, I know this issue pops up once in a while, but I haven't found a good answer to it. I need to debug a long running application under windows. The application is a combined java/python...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.