Results 1 to 4 of 4
- 08-05-2009, 02:44 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
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. :)
- 08-05-2009, 06:54 PM #2
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
there are a LOT of topics already on this with even more resources. you should definitely look for them
- 08-09-2009, 03:22 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 7
- Rep Power
- 0
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.
- 08-10-2009, 06:34 AM #4
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
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 BoyoIf 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
-
Executing java program using windows scheduler
By kanitha in forum New To JavaReplies: 0Last Post: 03-21-2009, 09:16 AM -
How do you start a Java program from the "Start" menu under Windows?
By ScottVal in forum New To JavaReplies: 5Last Post: 03-20-2009, 10:04 PM -
How can I make a program look and feel more windows-like?
By Exhonour in forum New To JavaReplies: 1Last Post: 01-16-2009, 10:15 PM -
Creating installer for java program
By priyanka.dandekar in forum Advanced JavaReplies: 9Last Post: 10-05-2008, 10:04 PM -
creating executable jars from Swing programs
By gotenks05 in forum New To JavaReplies: 2Last Post: 09-19-2008, 01:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks