Thursday, July 30, 2009

Is it possible to use java to launch an htm file that is saved in the home directory in a web browser?

Basically, can I have a button that launches IE or something to view an htm file that is inside Java's operating directory?

Is it possible to use java to launch an htm file that is saved in the home directory in a web browser?
Hello, yes it is possible. The only way is to do wrapper for Windows to open any file you want (like open up IE or Firefox or Adobe PDF) You have to use JNI to some windows system files.





But there is an open source JAVA package (which is developed by many JAVA SUN people which is windows specific) It is called JDesktop, you can download the JDIC Library.





They come as the following files:


1) jdic.jar - The JAVA Classes


2) jdic.dll - Some windows JNI Wrapper Call


3) WinMsiWrapper.dll - Another JNI Windows system dll





You copy the .dll to C:\ Windows \ System 32, or in the path.





Then you can do a simple code like this :) Very cool and easy!





============================


File testFile = new File("index.html");


Desktop.open(testFile);


============================





Then you will see your default browser open








I hope the above helped, it helped me in one of my contracts. Good Luck


No comments:

Post a Comment