• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with HP UX ia64 while using Process proc = Runtime.getRuntime().exec( command );

 
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
my test program does not seems to work on HP UX ia64 where as it works on Solaris and HP Ux PA
The JRE Version on HP UX ia64 is :
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0.08-_04_may_2007_06_31)
Java HotSpot(TM) Server VM (build 1.5.0.08 jinteg:05.04.07-11:53 IA64, mixed mode)

Here is my test program

The results always the following output

Program started...date..
Program Failed to execute.

________________________________________________________
java.lang.NullPointerException
at java.lang.StringBuffer.<init>(StringBuffer.java:113)
at test.DateTest.main(DateTest.java:17)
________________________________________________________

as far as I know, " in.readLine()" is returning null.. I meant the "Runtime.getRuntime().exec( command );" not returning any result.
It happening with only HP UX ia64.It works fine on Solaris and all other platforms..
please someone can help me...?

Thanks
Manjesh
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The output is probably sent to stderr, which you read using the getErrorStream() method. Or, and this is easier, dump Runtime.exec() and use ProcessBuilder instead. You can use it to redirect the process' error stream to its output stream, thereby allowing you to read it all from one stream.

And when working with Process, make sure to have read and understood this.
 
Manjesh Patil
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,
Thanks lot for your suggestions ,but unfortunately modified version of this program did not help me much

.
OUTPUT
----------------
<ERROR>
</ERROR>
DateTestModified: Process exitValue: 255

Its not printing the result of "date" command at all,
anyway the link you suggested me to look at is really nice..thanks for that
I suspect on JRE being used ..I am going to do more investigation on this.

Thanks again
Manjesh
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code you posted does not match the output. I tried it on my Ubuntu machine, and I got a NullPointerException. That makes sense, because the br.readLine() on line 20 is guaranteed to return null. After all, you've already read all data in the loop, and haven't reassigned br.
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've modified your code slightly to use ProcessBuilder with error redirection, and I get the desired output. The code:
 
Manjesh Patil
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,
Thanks for your time.
I took your modified program ,compiled it on Solaris box and executed it .It worked with the following output,
<DATA>
Tue Aug 2 09:03:46 IST 2011
</DATA>
DateTestModified: Process exitValue: 0

Then I copied the .class file to customer's box running HP-UX ia64 and tried executing ..it did not throw any error but failed to give output
<DATA>
</DATA>
DateTestModified: Process exitValue: 255

But the strange thing is the same code works fine in our local HP-UX machine!!!
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And when you run date from the console on the HP UX ia64 machine, do you get output? Perhaps it's not the Java code / JVM that's the problem but the date executable.
 
Manjesh Patil
Ranch Hand
Posts: 42
Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Rob,
Yes the bare unix commands used to work as usual ,the problem is only when you run those commands via Java Process API.
However now the problem is solved. I replaced the jre with the new jre from the box where it was working fine. I am thinking something was currupted inside the JRE..
So the problem is now resolved.
Thanks for your suggestions ..
-Manjesh
 
Rob Spoor
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome, and I'm glad you resolved the problem.
 
reply
    Bookmark Topic Watch Topic
  • New Topic