473,785 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.propertie s

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 12086
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_SIZ E=32768 com.my.main.Mai nClass
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.prop s" 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
4311
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. THe program creates a good number of threads. Any suggestions most welcome. Have tried following setting LD_ASSUME_KERNEL=2.2.5 disabling JIT by passing -Djava.compiler=NONE
1
10292
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 not sure, but the script seems more likely to work if I run it directly from bash. I was thinking of running a small script and, within the script, calling bash directly to execute the program, something like: #!/bin/bash bash...
9
1982
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 os.system(/paht/to shellscipt.sh) the python scipt waits for the exit of the shell script and then goes on with the rest of the python script. How to start a shell script without waiting for the exit of that shell
0
1714
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 address anymore. Anyone can help with the problems highlghted below?
11
22015
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 the changes disapear. So if this works for one statement it should also for a script, right ? I run the script with the following command: db2cmd -c -w -i db2 -t -f SCRIPT.SQL In this SCRIPT.SQL the connection to the database is made (CONNECT TO...
13
6009
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. The script is set to print a progress report to stdout every 3 seconds but I never see any output until the child process is killed. Here's what I have in my python script:
2
3252
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
1869
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 framework for testing ECUs in the automotive industry. Basically, the Java GUI (Eclipse-based) starts test-cases written in Python and provides the console where the test-logs are seen. When there is a exception somewhere in the testcases (or the...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.