• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Checked Exceptions - What did I wrong?

 
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exceptions – What did I wrong?

I corrected the program by catching the IOException but this error emerges:

Why this error? What can I do?
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ July 26, 2002: Message edited by: Dirk Schreckmann ]
 
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IOException belongs to another package. You are using the java.lang package which is always loaded by default. Use
import java.io.*;
as your first line of code.
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, even better, explicitly include just the class(es) you are using. In this case:
import java.io.IOException;
This helps people reading the source code to understand what classes it uses from which packages, and helps to prevent confusion when two imported packages have the same class name (e.g. java.awt.List and java.util.List).
 
Thomas Markl
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I run this program with JDK1.3 it works. When I run it with JDK1.4 it produces errors:

When I run this programm with jdk1.3 compiler this programm works.
When I run this programm with jdk1.4 compiler this programm throws this errors:
[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ July 26, 2002: Message edited by: Dirk Schreckmann ]
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code works fine on my computer running JDK and JRE 1.4.
I do notice that your code prints a specific message ("Exception caught: ") when an IOException is thrown and caught, and that this specific message is not being printed in your error message. Are you certain that you are running the same program?
"Die Zugriffsnummer ist nicht definiert" means "The access number is not defined" - I'm not sure what english version of this error message Java would produce.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm guessing it has nothing to do with this particular Java program, but with how the 1.4 JDK is installed or configured. Try compiling and running a simple "Hello World" in 1.4 to see if everything's OK.
 
Frank Carver
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't help noticing that your source code example is class Readtest1a, but the error message seems to arise from class Readtest1.
Are you really sure you are recompiling and running the class you think you are?
 
Thomas Markl
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
I tried to start Readtest1a from the DOS-Prompt and it worked.
Then I tried to start it from my texteditor with command: "DOS command to window" and I get this error messages.
What can I do?
Thomas.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic