getRuntime().exec problem
I have an application that was working good before I upgrade my OS/tomcat/java...
Now I have a problem with the getRuntime().exec
I'm passing the command and got an exit code 134
Seems that it try's to run the "C" program but without the good ENV
Java is start by the root user
I try also to add a su - oracle j command before to change user but it didn't work
We had java 1.3 and now we have 1.5
We had tomcat 3.2 and now we have 3.5
Somebody have an Idea of why it is not working like before ?
That's not really enough information, unless someone happens to know that runtime.exec has problems under the jvm/Tomcat versions you employ.
Why not tell us a bit more about what you are actually trying to do / run?
As to the 'su' Oracle thing you mentioned ... that just went flying past me.
~Bill
Well, sorry, my english is bad ;)
I'll try to explain
I'm executing this: Runtime.getRuntime().exec(itpcall)
itpcall contain a list of argument : a c program and parameter
The execution of this was working before I upgrade my java and tomcat.
Now it give's me an error 134 and like I can see, it didn't find my Oracle_home and oracle_base parameter
I assume that when it goes to the shell, it loss environnement variable
If I go directly in Unix, typing the same command as an oracle user, it's work but if i running this as root, I got the same error.
So the .exec is running as root as my java is start from root.
Is it more clear?
Yes, it is, of course, running the command as root.
You would be better off writing a script that sources the needed environment info, then executes the command. Then in your Java program execute the script as follows:
String[] cmd = { "su", "-", "oracle", "-c", "/full/path/to/script.sh" };
Runtime.getRuntime.exec(cmd);