aspose file tools
The moose likes Java in General and the fly likes Opening HTML file from a desktop application Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Opening HTML file from a desktop application" Watch "Opening HTML file from a desktop application" New topic
Author

Opening HTML file from a desktop application

Tomek Domek
Greenhorn

Joined: May 16, 2009
Posts: 4
Hi,

Can somebody help me. I have a fragment of code that is used to open HTML file from the C: drive in windows when a button is clicked. It did work perfect but one day it stopped working and I didn't do any changes inside the code, I really don't know why.

Here is the code (everything is in the actionPerformed method),the problem is only in the URI.

URI uri = new URI("file:///C:/new%20software/col.html");
uri.normalize();
Desktop.getDesktop().browse(uri);

The above code worked fine previously. I have noticed that if I will remove 'file:///' and '%20' and remove spaces then it works fine, but It also worked before without this changes.

Thanks for help.
jittu goud
Ranch Hand

Joined: Mar 30, 2007
Posts: 46
what error does it gives when it compiles ....
Tomek Domek
Greenhorn

Joined: May 16, 2009
Posts: 4

There are no errors at the compile time, also there are no exceptions being thrown at runtime and that's why I am cofused coz it worked well before
The file path is also correct, just nothing happens when a button is clicked and the problem is that html file is not opening. Do you have any idea what may cause this?

Thanks a lot
jittu goud
Ranch Hand

Joined: Mar 30, 2007
Posts: 46

not sure why its happening for you...
check the file you have referring is having correct path or not...try opening the file:///C:/new%20software/col.html in normal browser....
or may be some popup blocker software is blocking....

change your default browser...and disable any popup blockers...and try again...


I tried the followiing

and it works fine for me
Tomek Domek
Greenhorn

Joined: May 16, 2009
Posts: 4
Thanks very much

I've changed a browser to Firefox and now it works fine. But now I am very curious why it did suddenly stop working with IE .
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
One possibility - Java path and file names are always case sensitive - perhaps the use of case in the actual file name changed.

Bill


Java Resources at www.wbrogden.com
Tomek Domek
Greenhorn

Joined: May 16, 2009
Posts: 4

I was thinking that it might be because of that, but the file name and path are identical. With IE it works fine when I copy and paste it directly into browser but from inside the code it works only if I will remove file:/// and %20 and folder names are without the space character. I can't remind myself what I might have changed (if I did any changes) the day it stopped working
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Opening HTML file from a desktop application
 
Similar Threads
help, where to put servelet, html, jsp file
Lot of questions
unable to set the value of Internal attribute using <c:set>
how to read from file from a remote machine
Read File from jar file