?
Solved

Associate File Extension

Posted on 2003-11-26
20
Medium Priority
?
415 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
Industry Leaders: 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 252 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 248 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 real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month14 days, 3 hours left to enroll

800 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