• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Launch App from Windows Explorer and Open File

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I double-click on a file in Windows Explorer to launch a java app and have the java app read the file that I double-clicked?
I have created a batch file that looks like this:
java QuizCardReader
This java class is actually an enhanced version of the QuizCard app from Head First Java (Sierra and Bates). It reads input files containing question/answer pairs, and I have created some of these input files and given them an extension of ".qiz". I have also associated that extension with the batch file above, so when I double-click one of my ".qiz" files from Windows Explorer it runs the batch file and launches the QuizCard app.
What I would like is for the QuizCardReader class to open and load the ".qiz" file that I double-click. If there were a way to pass the path and filename as an arg to the class, that would do the trick.
Thanks in advance,
Tom
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D'oh! I just wrote up pretty much exactly what you're already doing. So, second try: When Windows starts your batch file, does it pass any arguments? I'd expect the filename to be in there.
[ December 21, 2003: Message edited by: Stan James ]
 
Tom Cockerline
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It turns out Windows Explorer passes the filename as the first argument to any apps it launches through extension association.
I modified the batch file to this:
java csci/quizcard/QuizCardReader %1
Now, the batch file passes along any arguments it receives from its caller (Windows Explorer in this case) to my java class. After modifying my class to conditionally handle the arg, it does what I was looking for.
Tom Cockerline
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tom Cockerline:
It turns out Windows Explorer passes the filename as the first argument to any apps it launches through extension association.
I modified the batch file to this:
java csci/quizcard/QuizCardReader %1
Now, the batch file passes along any arguments it receives from its caller (Windows Explorer in this case) to my java class. After modifying my class to conditionally handle the arg, it does what I was looking for.
Tom Cockerline


So finally did u make it work or not?
 
Tom Cockerline
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it works.
Now, I can double-click on one of my .qiz files and when my QuizCardReader starts it loads the .qiz file.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tom Cockerline:
Yes, it works.
Now, I can double-click on one of my .qiz files and when my QuizCardReader starts it loads the .qiz file.


That's great, Tom...
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic