Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi... I have created a program in java that shows the windows detail and also runs .exe files whose path is provided to it...

My question is will the same code do the same in linux?? I mean would it show OS to be linux and would run .bin files...

Help would be appreciated :-)
Java
import javax.swing.JOptionPane;
import java.util.Scanner;
public class Project1
{
	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		OSdetails();
		execute();
	}
	public static void OSdetails()
	{
		String osName= System.getProperty("os.name");
		System.out.println("Operating system name =>"+ osName);
		
		String osVersion= System.getProperty("os.version");
		System.out.println("Operating system version =>"+ osVersion);
		
		String osArch= System.getProperty("os.arch");
		System.out.println("Operating system name =>"+ osArch);
		//JOptionPane.showMessageDialog(null, osName +"\n"+ "Version: " +osVersion+ "\n"+ "Architecture: "+ osArch);
	}
	public static void execute()
	{
		Runtime r = Runtime.getRuntime();
		System.out.print("Please enter a path ");
		Scanner Input = new Scanner(System.in);
		String path = Input.nextLine();
		//String path = JOptionPane.showInputDialog("Please enter a path");
		Process p = null;
		try
		{
			if(path != "")
				p=r.exec(path);
			//System.out.print(path);
			
		}
		catch(Exception e)
		{
			System.out.println("File Not found");
			//execute();
		}
	}
}
Posted
Updated 28-Dec-11 4:45am
v2

1 solution

Yes, it should work (provided the *.bin file is a valid Linux executable). After all, Java is multiplatform, isn't it?
However why don't you try yourself on a Linux box?
 
Share this answer
 
Comments
umarbangash 28-Dec-11 11:59am    
Oh thnx for the response... I dont jave Linux on my pc... can u instruct me on how to test the code on linux environment easily.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900