Solved

Associate File Extension

Posted on 2003-11-26
20
368 Views
Last Modified: 2008-02-01
Right now I'm only talking about Windows, but if anyone knows how to do this under other platforms, feel free to post them.

Does anyone know how to associate a file extension under Windows without user interaction? I'm using InstallAnywhere to install my Java app on the users computer and would like to associate a file extension so that if they click on a file that my program saved, my program will open up.
0
Comment
Question by:LS9
  • 8
  • 5
  • 4
  • +1
20 Comments
 
LVL 92

Expert Comment

by:objects
ID: 9828852
It would involve adding a registry entry I would imagine.
0
 
LVL 92

Expert Comment

by:objects
ID: 9828862
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9828863
0
 
LVL 92

Expert Comment

by:objects
ID: 9828868
InstallAnywhere may have an option to do it for you.
0
 

Author Comment

by:LS9
ID: 9828873
I do not believe InstallAnywhere has an option, I have the free edition.
0
 
LVL 92

Expert Comment

by:objects
ID: 9828882
So what app do you want to handle setting up the association?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9829044
Check your system to see if you have the commands assoc and ftype. If so, you should be able to Runtime exec them
0
 

Author Comment

by:LS9
ID: 9834783
Is there a way to have the file that was double-clicked, call a specific method, or pass arguments to the program, the arguments would be saved inside the project file?

Thanks.
0
 
LVL 92

Accepted Solution

by:
objects earned 63 total points
ID: 9834977
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 24

Expert Comment

by:sciuriware
ID: 9835940
Like objects indicated, both on Windows and LINUX you can associate .jar with javaw
and you don't have any problem anymore.
Another concern is that many other products already do this for their own sake.
For instance: OpenOffice and MSWord "fight" for the .doc association,
MSMediaPlayer and RealPlayer "fight" for the .mp3 association and many more ....
;JOOP!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9836956
>>
Is there a way to have the file that was double-clicked, call a specific method, or pass arguments to the program, the arguments would be saved inside the project file?
>>

You would have to rearchive the jar file to do that every time you want to change the arguments you pass (which would have to be got from a file inside the jar).

You could perform an easier (and kludgier) way of changing the arguments from the command line using ftype if you were careful.
0
 
LVL 92

Expert Comment

by:objects
ID: 9839999
> You would have to rearchive the jar file to do that every time you want to change the arguments

no, you'd just read the args from the project file which you could store in the users directory or somewhere.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9842201
Yes, you could have external files for configuration
0
 

Author Comment

by:LS9
ID: 9842540
How would I detect if the program was initialized by the user w/o a project file, or if the program was opened from a project file, so that I can read the args from it.
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 62 total points
ID: 9842552
That would be decided by your program logic. For instance, if there were no command line arguments present, then load from config file, else use command line arguments.
0
 
LVL 92

Expert Comment

by:objects
ID: 9843362
> or if the program was opened from a project file, so that I can read the args from it.

If it was opened from a project file then the details of the project file would have to be included on the command line.

0
 

Author Comment

by:LS9
ID: 9843379
If it was opened from a project file then it would not necessarily pass args to the command line. In order for it to pass args to the command line, the program has to either be in the classpath or in a static location so that I would be able to do app.exe -args from the command line.

The project file would only contain words or numbers, not commands for the execution of the program.

So, to restate my question:  The user double clicks the project file, the program opens, loading the data from inside the project file.
0
 
LVL 92

Expert Comment

by:objects
ID: 9843444
> it would not necessarily pass args to the command line.

It would have to, otherwise your app wouldn't know which project file had been clicked on.
This is setup in the file association.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now