This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to find the full path of powerpoint.exe?

 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found it

RegistryKey.initialize("jRegistryKey");
 
James Swan
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Cathy for the jRegistryKey info
 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Always happy to help
 
js sj
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Jack Kay
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic