aspose file tools*
The moose likes Java in General and the fly likes how to find the full path of powerpoint.exe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to find the full path of powerpoint.exe? " Watch "how to find the full path of powerpoint.exe? " New topic
Author

how to find the full path of powerpoint.exe?

Cathy Song
Ranch Hand

Joined: Jul 01, 2003
Posts: 92
Hi All,

I want to open power point application from java. To be able to do this I need the full path of powerpoint.exe How can I find this? Also, I am trying to open a .htm file using power point.

Thanks,
Cathy.
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
To get the exact path on the user's machine, you'll probably going to have to dive into the Windows registry to retrieve that value:

eg.
on my machine I have this key (I've got office 2000, installed, so depending on the version of Office, the registry key value will be different):

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\PowerPoint\InstallRoot\Path

which has a value:
C:\Program Files\Microsoft Office\OFFICE11\

And to access the Windows registry from java, you'll need to read up on JNI (essentially you'll be invoking a c/c++ call from java).

As for opening an html file with PowerPoint, could it just be as simple as:

[path-to-powerpoint]/POWERPNT.EXE [myfile.html] ?
Dmitry Melnik
Ranch Hand

Joined: Dec 18, 2003
Posts: 328
You can also try to execute your .ppt file as a DOS command. If the PowerPoint is installed, and configured to be the default handler for files with .ppt extension (which is the default setting), the powerpoint will be started to open your file. Otherwise you'll get an error message.
[ July 13, 2004: Message edited by: Dmitry Melnik ]
Cathy Song
Ranch Hand

Joined: Jul 01, 2003
Posts: 92
Originally posted by James Swan:
To get the exact path on the user's machine, you'll probably going to have to dive into the Windows registry to retrieve that value:

eg.
on my machine I have this key (I've got office 2000, installed, so depending on the version of Office, the registry key value will be different):

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\PowerPoint\InstallRoot\Path

which has a value:
C:\Program Files\Microsoft Office\OFFICE11\

And to access the Windows registry from java, you'll need to read up on JNI (essentially you'll be invoking a c/c++ call from java).

As for opening an html file with PowerPoint, could it just be as simple as:

[path-to-powerpoint]/POWERPNT.EXE [myfile.html] ?



Yes. The following works just fine.

class Test{
public static void main (String args[]) throws Exception {
String file = "index.htm";
String cmd = "C:\\Program Files\\Microsoft Office\\Office10\\POWERPNT.EXE " + file;
System.out.println(cmd);
Runtime.getRuntime().exec(cmd);
}
}
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Keep in my Cathy that while that works on your machine, it won't always work on someone else's machine because:

A. They have a different version of PP, thus Office10 might be Office11 or just Office
B. They just installed it in a different place.

There really is no good way to handle this in Java sad to say.


GenRocket - Experts at Building Test Data
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

There is indeed a good and trivial way to do it in Java: use the methods of java.io.File to recursively search the disk until you find powerpnt.exe .


[Jess in Action][AskingGoodQuestions]
Cathy Song
Ranch Hand

Joined: Jul 01, 2003
Posts: 92
Hi,

I am using jRegistryKey to access the windows registry. It cab be found at http://sourceforge.net/projects/jregistrykey/

I tried to enumarate the keys but I am getting a runtime expection saying

java.lang.IllegalStateException: You must successfuly call method initialize before calling this method.
at ca.beq.util.win32.registry.RegistryKey.checkInitialized(RegistryKey.java:183)
at ca.beq.util.win32.registry.RegistryKey.<init>(RegistryKey.java:235)
at Test.main(Test.java:31)
Exception in thread "main"


Has anyone used this software before?

Thanks,
Cathy.
Cathy Song
Ranch Hand

Joined: Jul 01, 2003
Posts: 92
Found it

RegistryKey.initialize("jRegistryKey");
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
Thanks Cathy for the jRegistryKey info
Cathy Song
Ranch Hand

Joined: Jul 01, 2003
Posts: 92
Always happy to help
js sj
Greenhorn

Joined: Jul 27, 2004
Posts: 1
HELP!!!
I'm using JRegisterKey 1.1.
I've tryed it with eclipse but it don't work :

-with method :
RegistryKey.initialize("jRegistryKey");

-I have these errors :
RegistryKey.initialize();

java.lang.UnsatisfiedLinkError: no jRegistryKey in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1491)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at ca.beq.util.win32.registry.RegistryKey.initialize(RegistryKey.java:156)
at TestJNI.main(TestJNI.java:20)
Exception in thread "main"


Can someone help me?
James Swan
Ranch Hand

Joined: Jun 26, 2001
Posts: 403
1) You're gonna get hammered by the moderators to change your display name

2) the nature of that error is the ".dll" associated with JRegistryKey can not be found in your "path" when invoking System.loadLibrary(). I'm not all that familiar with Eclipse, but try adding the location to that ".dll" to your "path" variable in Eclipse.
[ July 27, 2004: Message edited by: James Swan ]
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Originally posted by Ernest Friedman-Hill:
There is indeed a good and trivial way to do it in Java: use the methods of java.io.File to recursively search the disk until you find powerpnt.exe .

And how do you find out which drives exist?
Test every letter from 'a-z' and try-catch?

At least, you should search all the disks until you find all powerpnt.exeS, and let the user decide which to use.

Are network-drives allways matched to a letter?

I guess I would give the user a FileChooser-Dialog where he can pick it himself.
[ July 27, 2004: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
Jack Kay
Ranch Hand

Joined: Aug 01, 2004
Posts: 62
I'd first try the default path:
String cmd = "C:\\Program Files\\Microsoft Office\\Office10\\POWERPNT.EXE " + file;

And if that doesn't work...System.exit(1)....lol..no no,
I'd pop a window up that the user can browse through to find where the powerpnt.exe is OR have them hardcode it into the commandline.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to find the full path of powerpoint.exe?