File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes compiling package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "compiling package" Watch "compiling package" New topic

compiling package

Pradyut Bhattacharya
Ranch Hand

Joined: Aug 12, 2004
Posts: 63
i have created a package with the file name as : -

it compiles without any errors

but on calling it from this file

and on compiling in command prompt as

javac -classpath D:\java\p9\

it gives the error message

bad class file: D:\java\p9\lmn.class
class file contains wrong class: p9.lmn
Please remove or make sure it appears in the correct subdirectory of the classpa
lmn obj = new lmn();

pls help


Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Both lmn and xyz are in the same package so you don't need to use an import statement. Besides, the import statement imports a class lmn from package nine but the class you showed is in package p9. If you simply remove the "import nine.lmn" statement, it will fix this particular error.

As a side note, it would be helpful if you start class names with uppercase and use CamelCase if the name contains more than one word. Also, variable names should use camelCase but start with a lowercase letter instead. Finally, package names are typically all lowercase.

If you follow these conventions, it will be much easier for us to read your code when you ask for help here. You may also find it helps YOU read your own code more easily.

Keep Coding! (TM)


Java API Documentation
The Java Tutorial
cocoloco cocotero

Joined: Nov 29, 2004
Posts: 4
try this

1) create file
2) create a folder called p9 that supend from directory where xyz is included
2) create file in this folder (the package name refer to directory p9) and compile
3) compile now file
4) execute xyz.

this should work.


Hola Caracola
I agree. Here's the link:
subject: compiling package
It's not a secret anymore!