File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes batch file run from Windows or Linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "batch file run from Windows or Linux" Watch "batch file run from Windows or Linux" New topic
Author

batch file run from Windows or Linux

Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
i got success in running a batch file on windows platform. but want to run batch file equivalent in Linux and write the code in same class from which i executed batch file of windows. means my application may reside on windows or Linux. so i want to make such code that i don't need to worry about the batch extension or other extension for corresponding OS.

for ex.

method(){
{
// code goes here
// now i want such code that my program will detect which OS i have
// and excecute batch file if it is windows OR .sh (i think so) if
// my OS is Linux.
}

how can i do this. please tell me


Perform for today. Adapt for tomorrow.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

System.getProperty("os.name");
System.getProperty("os.version");

Tutorial available at sun:
Essential Classes - The Platform Environment - System Properties

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
Rahul Shilpakar
Ranch Hand

Joined: Aug 29, 2006
Posts: 132
yes i got it. thank you very much. now i just need to detect my OS and then execute the corresponding batch file extension after checking the condition.

OK, fine.





Software metrics let you know when to laugh and when to cry.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: batch file run from Windows or Linux
 
Similar Threads
Chron jobs?
run a batch file (.bat) from java programm (.java)
core java doubt
Batch File
file Path representation in different OS??