Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Java Runtime command syntax help  RSS feed

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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
  • 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: 21747
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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: 21747
102
Chrome Eclipse IDE Java Spring Ubuntu VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
Olivier López
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
The human mind is a dangerous plaything. This tiny ad is pretty safe:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!