aspose file tools*
The moose likes Java in General and the fly likes Java Runtime command syntax help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Runtime command syntax help" Watch "Java Runtime command syntax help" New topic
Author

Java Runtime command syntax help

Olivier López
Ranch Hand

Joined: Jan 31, 2010
Posts: 32
Hello Greenhorns¡

Im trying to run a command on using the java Runtime Class, but here's my problem.
If i run this, it works perfect:




I want to run "java -version" in the CMD parameter, so i can get the java version installed on the pc, but the runtime method doesnt return anything:



Do you have any idea about why it doesnt return anything? Is the command syntax wrong?

Thanks in advanced¡
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

Hi Olivier López,

I don't think there is anything wrong in your code. The problem here is (even I don't know the reason) - java -version is not returning anything to stream.
e.g. if you simply run java instead of java -version from your code, it'll give you expected output. But I'm not aware about reason behind this behavior of java -version.

Apart from that, if you want to check java version pro grammatically, this thread might be helpful.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19757
    
  20

A lot of programs write version and help information to the error stream instead of the output stream.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

Rob Spoor wrote:A lot of programs write version and help information to the error stream instead of the output stream.

Thanks Rob. It solved my doubt
Instead of it should be
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19757
    
  20

You're welcome.
Olivier López
Ranch Hand

Joined: Jan 31, 2010
Posts: 32
Thanks to all for your responses¡
I tried using the errorStream instead of the inputStream, but it didnt make any difference.
My main goal is to know if the application is running with java 32 or 6bits, so I believe i will end solving it by using System.Property(java.home). It returns the path were java is installed, but it believe
that i can play with that path, like checking if it contains "(x86)" then the JVM being used should be 32bits, otherwise it is 64bits.
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1509
    
    5

Olivier López wrote:My main goal is to know if the application is running with java 32 or 6bits

All you need is this:I hope this helps.
Olivier López
Ranch Hand

Joined: Jan 31, 2010
Posts: 32
I was just going to post that I tried System.getProperty("sun.arch.data.model") and it worked like a charm, thats exactly what i was looking for.

Thanks for all of your responses.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Runtime command syntax help