Package organisation

Hello,

I'm getting this message...

CountWordWin.java:8: CountWordWin clashes with package of same name

public class CountWordWin extends JFrame {

^

1 error

I assume this means I have to put my class in a package instead of using the default one, how do I do this and how should I name them and organise my files/folder to conform to conventions?

I know it has somthing to do with my home page address www.nickhanlon.co.uk, named something like "package co.uk.nickhanlon.countwordwin;"

Please help, and thank you

Nick Hanlon

[592 byte] By [nhanlon] at [2007-9-26 2:21:53]
# 1
A package has the same name as your class, so you'll have to rename one of them.
alee1010 at 2007-6-29 9:27:43 > top of Java-index,Archived Forums,Java Programming...
# 2
I would still like to know how to organise my packages etc. and I only get this error when my class has the same name as the directory its in, I have tried changing the name to something obscure but the error still occurs.
nhanlon at 2007-6-29 9:27:43 > top of Java-index,Archived Forums,Java Programming...
# 3

Getting that errors simply means that your package and the class has the same name.

I don't know if you know this, but basically a directory denotes a package and/or subpackage.

so that means if your package is

co.uk.nickhanlan.countwordwin

your directory would be

+-co

+-uk

+-nickhanlan

+-countwordwin

- countWordWin.java

The easiest way is to change your java's file name to something else so it won't clash with the pacakge name. Changing the directory name will do, BUT it might affect other classes that is sharing the same directory.

Remember to change your public class XXX name as well as any default and non-default constructor.

hope it helps.

javaVivian at 2007-6-29 9:27:43 > top of Java-index,Archived Forums,Java Programming...
# 4
Excellant this is what I wanted to know :)
nhanlon at 2007-6-29 9:27:43 > top of Java-index,Archived Forums,Java Programming...