wood burning stoves 2.0*
The moose likes Java in General and the fly likes linux or windows Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "linux or windows" Watch "linux or windows" New topic
Author

linux or windows

marys joseph
Greenhorn

Joined: May 14, 2004
Posts: 20
hi,

I need to check if the machine is in linux or windows how can I check it?

also as we call .exe files for windows how can we do that in linux

thanks
Jason Fox
Ranch Hand

Joined: Jan 22, 2004
Posts: 114
You can query System.getProperties to find out, for System.getProperty(String), I'm not what string returns the OS, but it shouldn't be too difficult to find. As far as executing something in Linux, it works a little differently than on Windows. Linux relies on permissions, rather than on file extensions to tell it which apps are executable. You will need to set the permissions to executable using the chmod command.
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823

Not exactly advanced IMHO, hence I can answer! You run an executable under Linux in basically the same way as under Windows. As Jason says, the file must have execute permission.

Jules
marys joseph
Greenhorn

Joined: May 14, 2004
Posts: 20
thanks all for replying. I need to do "ping" and " traceroute" using java. I am opening a ".exe" to do. that's why I need to know the system prop so that the correct cmd is excuted.

thanks again,

I will try to find system.getproperty(string)
Jason Fox
Ranch Hand

Joined: Jan 22, 2004
Posts: 114
Unless you are using an emulator, WINE, or something similiar, a windows executable shouldn't run under Linux. However, traceroute and ping are both programs included in most Linux distros. If they are in your path, simply type traceroute <options> or ping<options> and it should work. If not, you may have to go digging to find them.
marys joseph
Greenhorn

Joined: May 14, 2004
Posts: 20
I am using ping.exe if os is windows if it is linux I call ping or traceroute.

thanks,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: linux or windows