Hi Guys,

I have a compiled java file example.class and i need to use the methods in this file to read from a text file.

I need to have this file inside my package as requested by the teacher. However when i put the example.class file into my package and write example eg=new example(); it complains that it doesn't exist ive decompiled example.class and i know for a fact it has a constructor as example().

8 Years
Discussion Span
Last Post by gonzila

Does it have a "package" statement? Probably not. You need to do more than simply copy the "class" file around. You have to actually declare the package in the source file and compile it as such.


Are you sure its "example" not "Example". Java is case-sensitive, and the convention is that class names always begin with a capital letter, so "example" would be a bad example for a class name.


Hi guys, Thank you for your help. One important thing i forgot to say is that im working with Netbeans.
The solution was to place the .class file into the package and than right click on the Libraries -> add folder/file and add the project directory in which the package containing .class files is found.

Thank you!!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.