wood burning stoves*
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
Author

compiling package

Pradyut Bhattacharya
Ranch Hand

Joined: Aug 12, 2004
Posts: 63
i have created a package with the file name lmn.java 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\ xyz.java

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
th.
lmn obj = new lmn();
^

pls help

thanks
Pradyut


Pradyut
http://pradyut.tk/
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)

Layne


Java API Documentation
The Java Tutorial
cocoloco cocotero
Greenhorn

Joined: Nov 29, 2004
Posts: 4
try this

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

this should work.

Regards.


Hola Caracola
 
Don't get me started about those stupid light bulbs.
 
subject: compiling package
 
Similar Threads
Package Question
Package problems
How to refresh a StringBuffer object for creating a HashMap object
BoxLayout: unsihtly vertical gap betw components?
How to import classes in a subpackage from another sub-package?