By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,152 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

Running long java command from solaris shell script

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.