Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Inconsistent FileNotFoundException

Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web server and a client applet to have chat functionality between server and client. If I run the applet on a different machine other than where the server is, it works just fine.
But if I try to run the applet from the same machine ie., http:\\localhost ort\chat.html, then applet fails to load and I get a series of for many of the library jar files.
Not only that, it has so many inconsistent behavior in different machines (but atleast it gets loaded in all those machines). BTW, its a signed applet.
I am really confused about this behavior of my applet... it will be really helpful if somebody can help me out in solving this problem.
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is you're using pathname-based URLs for your files rather than classpath-based ones.
For example, instead of:
InputStream s = Something.openStream("file name here");
you should use:
URL resource = getClass().getResource("file name here");
InputStream s = Something.openStream(resource);
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic