wood burning stoves
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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 file.it 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: http://aspose.com/file-tools
subject: package declaration
jQuery in Action, 3rd edition