Results 1 to 4 of 4
  1. #1
    rolls is offline Member
    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    Default Creating a java program that acts like a normal windows executable?

    I know you can compile java programs into a single .jar file that you can execute but I have a problem and I want to know if it can be solved.

    Now I have a custom file format that has the extension .dta the files contain some data to create a graph. Now I want to be able to double click these files and have them open in my java program. Also if the program is already open I want any further files that are opened (not via the file > open functionality) to open in this same instance of the application.

    How can I do this and what would be the best way. Should I use a separate launcher application written in say C# that calls the java -jar application.jar filename? Or is there an easier way to do this.

    Thanks in advance. :)

  2. #2
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    6

    Default

    there are a LOT of topics already on this with even more resources. you should definitely look for them

  3. #3
    rolls is offline Member
    Join Date
    Mar 2009
    Posts
    7
    Rep Power
    0

    Default

    Ok I've settled on a batch file or a launcher written in C to load the jar file, now we have one more problem.

    How do I open multiple files in the same instance? For example I double click a .dta (the file type I am associating with my program) file which is linked to my launcher (bat or exe), this then loads up my jar file with the .dta file as an argument, all loads as expected. I now double click a second .dta file and the same occurs, however it has now loaded two instances of my program. What I would ultimately like is to have both files open in the same instance (my program is a tabbed window with multiple graphs showing, file > open works as expected, however if a users double clicks multiple .dta files it doesn't.)

    Now I've done some research and found an answer for windows using JNA or JNI or JWinApi to call the FindWindow function from the user32.dll. If FindWindow(NULL,"My Program's Title") does not equal NULL, then there is an instance open and so on. I will need to do some more research and lots of testing.

    Now this method sounds fairly complicated, I was wondering if there was anything built into java that can simplify this problem.

    Thanks for any help, really appreciate it.

  4. #4
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    Create a temporary file (this can also be used to check if the file selected is already open) and see if it exists. If it does there is an instance already running, so somehow ping the program and tell it to open the file (that I'll leave to you... possibly an indicator in front of filenames indicating that they have been opened?)

    There may be other ways, but this could work as well.

    Good Luck,
    Singing Boyo
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

Similar Threads

  1. Executing java program using windows scheduler
    By kanitha in forum New To Java
    Replies: 0
    Last Post: 03-21-2009, 09:16 AM
  2. Replies: 5
    Last Post: 03-20-2009, 10:04 PM
  3. Replies: 1
    Last Post: 01-16-2009, 10:15 PM
  4. Creating installer for java program
    By priyanka.dandekar in forum Advanced Java
    Replies: 9
    Last Post: 10-05-2008, 10:04 PM
  5. creating executable jars from Swing programs
    By gotenks05 in forum New To Java
    Replies: 2
    Last Post: 09-19-2008, 01:51 AM

Posting Permissions

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