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().

Recommended Answers

All 3 Replies

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!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.