Using a .class file without a .java source file in Netbeans - java cannot find symbol
posted 7 years ago
I have a precompiled utility class that was provided by the professor. It is named Utility.class and has a few premade functions we can call.
It works fine in the simple tool we use at school, but when I try to use it with a project in netbeans, I get java cannot find symbol error.
I've copied it into the folder with my source files:
The package name is myapp, so I've tried adding:
...but it didn't make any difference.
I tried placing it into:
...and it gets erased when I build.
I edited the project properties and selected Libraries, thinking I should be able to make a reference in there, but that seems to want a folder of precompiled jar files and I'm not sure how to make the transition.
I'm just stumped.
Does anyone have any clue where to put a .class file so my app can find a ref to it in netbeans?
1. In the Project, right click LibrariesAdd Jar/Folder.
2. Add the folder that contains your Java classes.
Suppose your classes are in the myapp package and you put them in the /home/user/myapp/classes/myapp/*.class, then you need to select /home/user/myapp/classes and NOT /home/user/myapp/classes/myapp/. If you understand the classpath concept, you should know why
Hope that helps.
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4