Solved

Associate File Extension

Posted on 2003-11-26
20
397 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
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
by zero exception 10 70
Print Rhino Java Array in Javascript 1 35
Running JavaFX on the Raspberry Pi 27 131
Java class and jar 3 42
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

756 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