• 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Need help folks: Generating a DOS window.

 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A Java application of mine is being started from an MFC (Microsoft C++) application using a Windows system command ::ShellExecute(..., "open", "thejavaapplication.jar", ...).

Doing this causes (I think) javaw.exe to execute instead of java.exe which means that no DOS window gets brought up.

Well, I need a DOS window in order to get a thread dump so I need to have the ShellExecute point to java.exe instead of javaw.exe.

Anyone know how to do this?

Sorry, I know this isn't a pure Java question, but it is Java related.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Darrin,

I don't know the ShellExecute() syntax but... can't you ask for excuting "java -jar thejavaapp.jar" rather than asking the OS to open a jar file ?

I hope that could help,
Best regards
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't get a DOS window in any Windows version newer than Windows 95.

ShellExecute can be used to load an arbitrary executable, the only reason it takes javaw on your machine is because that's set up to launch jar files by default.
Give the complete commandline and that's what gets executed in a command window.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that would work, but the process of using the ShellExecute is already in place.

I might just rename javaw.exe to something else then copy java.exe to javaw.exe and give that a try.
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen Wenting:
You can't get a DOS window in any Windows version newer than Windows 95.

ShellExecute can be used to load an arbitrary executable, the only reason it takes javaw on your machine is because that's set up to launch jar files by default.
Give the complete commandline and that's what gets executed in a command window.



Are you saying that there is a way to send the complete command line to ShellExecute?
 
Darrin Smith
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, here is the way it is done...simple association in Windows!

Interactively: Double click My Computer. Choose Tools->Folder Options->File
Types from the menu. Scroll down to JAR, click Advanced, click Edit.

Programmatically:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_extending/fileassociations/fileassoc.asp
 
Whatever. Here's a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic