This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes package declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "package declaration" Watch "package declaration" New topic

package declaration


Joined: Oct 12, 2000
Posts: 2
hi ,
i am a beginner in this Java Forum.I have one problem.
my classpath is set to \jdk1.3\projects
and my all .java files lies there. Now when i include "package projects" in my java compiles but give run time error as
"Exception in thread main.. Wrong name projects
But when i remove "package projects" from the java file it works fine.
Kishan Kumar
Ranch Hand

Joined: Sep 26, 2000
Posts: 130
since you have set your classpath till the projects directory
this wont work. try setting the classpath = c:\jdk1.3
this should work. packages take the classpath as the base and
tries to find the package from there. In your case it is trying
to find c:\jdk1.3\projects\projects which is not existing.
If there was a directory like that it would have worked.
set classpath = c:\jdk1.3
package projects.kishan.kumar;
will search for the directory
c:\jdk1.3\projects\kishan\kumar to put the class files.
Please remember declaring packages inside the file will not
create directories in the file system. you should first explicitly create files and the compile the program containing the package statement or else it will result in the compile time
Hope this helps and hope i have not confused you.

V. Kishan Kumar

Regards,<BR>V. Kishan Kumar
I agree. Here's the link:
subject: package declaration
Similar Threads
An HTML question
WSAD 5.1 Servlet & JSP Features
Exception creating bean of class
organizing java projects
adding libraries into a netbeans project?