Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31
  1. #21
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Embedding an external executable inside a Java program

    It's not a new thing (though I've never used it).
    deleteOnExit().

  2. #22
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Embedding an external executable inside a Java program

    Ok, another error
    I got a jar file which creates the file.
    Let's call the jar file x and the new file y.
    So x creates y and delete y after I close x.
    But if x creates y, and then I launch y and close x, y is still exists after I close it.
    Do you have any suggestions how to delete y even if I launch it?(of course after I close it, not in run time).

  3. #23
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Embedding an external executable inside a Java program

    You can't.
    Because Java cannot delete something that something else on the OS is holding open.

  4. #24
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Embedding an external executable inside a Java program

    So do you have any idea how will I do it?maybe with some external code?maybe another code that run while the game is open or in other words while the port is in used and when it's open delete that file.
    lol while typing I just wrote a good idea didn't I?

  5. #25
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Embedding an external executable inside a Java program

    Do you control the exe?
    That is, is it your code?

  6. #26
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Embedding an external executable inside a Java program

    This is not my code.
    I can't tell you all of the details but I'm not doing anything that is illegal if thats what you'r looking for.
    All I got is an exe, so any edit that I want to do would be in assembly :( which is kinda my weakness.

  7. #27
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Embedding an external executable inside a Java program

    I was going to suggest that the app you are trying to launch could simply check whether it is already running, and thus exit straight away.
    But if you're reduced to assembly that might prove a bit of a challenge...:)

  8. #28
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Embedding an external executable inside a Java program

    So in that case, my idea is good?
    Run a code that checks every x time if this port is in used and when not it will be deleted?

  9. #29
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Embedding an external executable inside a Java program

    No, what I mean is the exe you are trying to run would check whether it was already being executed (a process search) and, if so, simply exit.
    It's unlikely you'll be able to delete an exe that is currently running. Might work, but I'd be surprised.

  10. #30
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Embedding an external executable inside a Java program

    Is there any way to do any kind of a change on an exe by java?
    As far as I know the only way is by assembly, and it's not my strong side.
    Or maybe combine alittle bit of assembly, and alot of java :)
    Something like linking from the exe by assembly to an external code writed in java, something like this.
    Because all the download part wouldn't be ncessary if the client will start only if the launcher is running (on the memory).

    Thanks.

  11. #31
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,755
    Rep Power
    19

    Default Re: Embedding an external executable inside a Java program

    You're getting into OS area I suspect.
    That exe has to exist on the system to run.
    Whether it is removable once it is up and running will be OS specific.

    Java itself is unlikely (short of simply editing the exe itself) to be able to affect the executable, unless said exe ha sprovided mechanisms for interacting with it.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Open external file with external program
    By Wietse de Vries in forum New To Java
    Replies: 1
    Last Post: 12-31-2011, 04:52 PM
  2. Replies: 3
    Last Post: 08-10-2009, 06:34 AM
  3. Execute external program from java
    By ankitmcgill in forum New To Java
    Replies: 1
    Last Post: 06-01-2009, 03:58 AM
  4. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 09:33 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
  •