Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Opening HTML file from a desktop application

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what error does it gives when it compiles ....
 
Tomek Domek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One possibility - Java path and file names are always case sensitive - perhaps the use of case in the actual file name changed.

Bill
 
Tomek Domek
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic