• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Java Runtime command syntax help

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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¡
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 22656
126
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
A lot of programs write version and help information to the error stream instead of the output stream.
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 22656
126
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.
 
Olivier López
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1558
5
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic