Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Associate File Extension

Posted on 2003-11-26
20
Medium Priority
?
418 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
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 …
Suggested Courses

636 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