Results 1 to 10 of 10
  1. #1
    tony_lincoln is offline Member
    Join Date
    Mar 2010
    Posts
    3
    Rep Power
    0

    Default Under Windows OS, how to call *.EXE produced in Linux OS?

    Hey,

    My colleague likes Linux very much and he produced one EXE file under Linux. I tried to call it from Windowns OS, which is my favorite OS, but it did not work!
    I used some methods like Runtime.getRuntime().exec:
    Execute an external program - Real's Java How-to

    Does anyone have some experience how to make it work? I will appreciate it a lot!
    Best wishes.
    Tony

  2. #2
    iluxa is offline Senior Member
    Join Date
    Mar 2010
    Posts
    266
    Rep Power
    5

    Default

    It won't work at all :( doesn't even have to do with Java, try double-clicking the .EXE and it won't work :(

    .EXEs are platform-dependent: the ones for Linux work ONLY on Linux, the ones for Windows work ONLY on Windows etc.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,003
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by iluxa View Post
    .EXEs are platform-dependent: the ones for Linux work ONLY on Linux, the ones for Windows work ONLY on Windows etc.
    It's even worse than that; I have a Linux running on a small Atmel box and I have another Linux running on 32 and 64 bits Intel boxes but none will run the other's executable binaries ;-)

    kind regards,

    Jos

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    The discovery that executable files are dependent on the OS has also been reported by the OP at forums.sun.com

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,003
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by pbrockway2 View Post
    The discovery that executable files are dependent on the OS has also been reported by the OP at forums.sun.com
    I wrote a little program for my cell phone lately but it didn't run on my espresso machine. The OP is a Samaritan for warning us about this mishap.

    kind regards,

    Jos

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,189
    Rep Power
    19

  7. #7
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Boy, he just seems to be bound and determined to find someone to tell him it can be done. Well, OP, here is that person. Reinstall that machine that has Windows, with the same Linux version that created the "EXE", and you should be able to execute on that machine.

  8. #8
    tony_lincoln is offline Member
    Join Date
    Mar 2010
    Posts
    3
    Rep Power
    0

    Default thanks for reply, but none of the suggestions can really work, I guess

    I appreciate all replies. I need to address my question in a better way:
    1. This EXE can be executed in Windows OS: just double click it, and one window will pop up and ask you to input some numbers (such as 0.995, 1, 0.2) as parameters, after that it will run.
    2. what I wanna do is: call this EXE directly from my java codes, so the user of my codes will not have access to this EXE any more, the java codes will call it automatically, and java codes should be able to input these numbers automatically, and the EXE will then run automatically. This is to be user friendly --- the user of my codes is from another major, or is even a dog. The user does not want to know too much details about parameters. He just wanna get result by simply clicking my java codes ---- but not input too much parameters.
    3. The codes I used are:

    **************BEGIN***************************
    import java.io.*;
    public class CmdExec {

    public static void main(String argv[]) {
    try {

    String line;
    Process p = Runtime.getRuntime().exec
    // (System.getenv("windir") +"\\system32\\"+"tree.com /A");
    ("AA.exe");

    BufferedReader input =
    new BufferedReader
    (new InputStreamReader(p.getInputStream()));
    while ((line = input.readLine()) != null) {
    System.out.println(line);
    }

    input.close();
    }
    catch (Exception err) {
    err.printStackTrace();
    }
    }
    }

    *****************END****************************

    AA.exe is EXE I mentioned above. When I run it, I got a dialog popped up, it says:
    _________________________________________________|
    | 16 bit MS-DOS Subsystem |
    | C:\WINDOWS\system32\ntvdm.exe |
    | Error while setting up environment for the application. |
    | Choose 'Close' to terminate the application. |
    | close ignore |
    |_________________________________________________ |

    Either I press close, or ignore, my java codes finished running. There is no window popped up and asked you to input some numbers (such as 0.995, 1, 0.2) as parameters. Nothing. The java codes just finished after the dialog popped up.

    This is what I mean "Runtime.getRuntime().exec" can not work.

    4. I do NOT have source codes about this EXE, what I have is just this EXE produced in Linux OS. Lauch4j wraps JAR into EXE, so it can not be used to call EXE directly from Java source codes. The other suggestions from some of you sound not realistic.

    But I do appreciate all answers from you and let me know how you think about my question.
    Thank you.
    Tony

  9. #9
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Then, before this goes any further, see this and implement all of it's recommendations.

  10. #10
    tony_lincoln is offline Member
    Join Date
    Mar 2010
    Posts
    3
    Rep Power
    0

    Default

    Cool, this is a good article. Thanks a lot. I will read it and try to find whether there is a solution.
    Thanks again

Similar Threads

  1. Errors running app in linux but not in Windows
    By JohnST in forum New To Java
    Replies: 3
    Last Post: 03-12-2010, 01:58 AM
  2. Replies: 3
    Last Post: 01-21-2010, 01:51 AM
  3. Replies: 6
    Last Post: 04-08-2009, 04:05 AM
  4. Character encoding in Java (Linux to Windows)
    By BeholdMyGlory in forum New To Java
    Replies: 2
    Last Post: 01-16-2009, 06:24 PM
  5. Access Linux shared folder from Windows OS
    By nitinpjairaj in forum Networking
    Replies: 3
    Last Post: 08-26-2008, 06:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •