I can't compile packages created by NetBeans
Hello guys
for the previous weeks, I was developing my project using Notepad for editing, and javac from the command prompt. Recently I moved my work into NetBeans 3.6, and i modified my code greatly, by arranging my java files into packages and I thought I had accomplished a great step by making my job easier. what I found later is that I can no longer compile my code using the normal javac command, because it's unable to reach the packages in the same way netbeans do.
My java files are distributed inside the senior directory :
senior \ Senior.java
senior \ menu \ menuBar.java
senior \ menu \ toolsBar \ *.*
senior \ Buttons \ *.java
senior \ images
The Senior.java conatins the following imports:
import senior.menu.menuBar;
import senior.Buttons.*;
These imports are located fine in NetBeans, but Javac command can't locate them.
Please advise me, should I continue working with NetBeans, or should I use a format that is compatible with javac?
and what other differences I might face in the future between NetBeans and Javac?
NetBeans and javac are perfectly compatible. No need to stop using the IDE. You're simply running into classic (and easy to work through) Java package issues.
Make sure your java source files have a "package" statement defining which package they belong to (reflecting the directory it belongs to).
Note also that packages are not recursive/hierachical: you need to compile each package, not simply to top one -
javac senior\Senior.java senior\menu\menuBar.java senior\menu\toolsBar \*.java senior\Buttons\*.java
-Alexis
I have a similar problem. I'm using NetBeans 3.5. I have 2 java files in a package called mypac. The first one is a JavaBean (implements Serializable) and the second one is a servlet (extends HttpServlet). The JavaBean contains a class called user and the servlet has a private data member of type user. Both files have the "package mypac;" statement at the first line.
I can build the JavaBean successfully but when I tried to build the servlet, it happened that the user class is unrecognised in the servlet. (Cannot resolve symbol error)
What should I do to solve this problem?
21tk at 2007-7-7 2:31:30 >
