Solved

Associate File Extension

Posted on 2003-11-26
20
407 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

707 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