Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

determining runtime platform in runtime  RSS feed

 
Pallab Sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

How can we determine the platform at run-time .

Our requirement is something like below.

We want to do some processing of files, based on platforms like Windows or Linux.
In C, we have #ifdef , what's the equivalent for it in Java ?

Regards,
Pallab
 
Pallab Sen
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I myself found the reply , courtsey google search.

The following line returned me the OS name.

String OSName = System.getProperty("os.name").toLowerCase();

-- Pallab
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, but that is not the same as #ifdef in C, because that is a preprocessor directive, which is processed at compile time, not at runtime.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!