Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » error: public type XYZ must be defined in its own file
error: public type XYZ must be defined in its own file [message #158443] Wed, 12 May 2004 14:08 Go to next message
Eclipse UserFriend
Originally posted by: bruce.coding-r-us.com

I am new to Java and Eclipse, but based on experience from C# and Visual
Studio, I am learning fast. I have successfully built a couple of small
projects, so I am not completely new to this game.

Today, I started a new project that involves a class called SpellChecker,
which resides in its own file called SpellChecker.java. Eclipse gives me
an error: "The public type SpellChecker must be defined in its own file."

I have three questions (which I've already researched extensively in
Eclipse help, Google, and searching these newsgroups... but oddly no luck
so far.)...

1.) Why would I get this error? The class is in a file of its own, which
shares the name of the class. The class is the only class in the file.

2.) Within the Eclipse IDE, how can I request more detailed information
about an error message? I see the same error message by hovering my mouse
over the SpellChecker class declaration and also I see it in the "Tasks"
pane. But I cannot find a mechanisme in either case to link to more info.

3.) One broader question about the IDE... if I utilize a java system
class name or method name in my code (like "ArrayList" or
"myArrayList.size()" respectively) and I want to access documentation for
that item, what is a quick way to get from the name in the code to the
associated documentation?

Many thanks,
-- Bruce
Re: error: public type XYZ must be defined in its own file [message #158452 is a reply to message #158443] Wed, 12 May 2004 14:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomannNO.ca.ibm.comSPAM

Le Wed, 12 May 2004 18:08:08 +0000 (UTC), bruce@coding-r-us.com (Bruce
Schechter) a écrit :
>Today, I started a new project that involves a class called SpellChecker,
>which resides in its own file called SpellChecker.java. Eclipse gives me
>an error: "The public type SpellChecker must be defined in its own file."
Are you sure the case is the same for the file name and the public
type?
--
Olivier
Re: error: public type XYZ must be defined in its own file [message #158460 is a reply to message #158452] Wed, 12 May 2004 14:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bruce.coding-r-us.com

Olivier, you were correct. I did have a case mismatch. Thanks!

Never-the-less, I would still appreciate help from someone on parts 2. and
3. of my questions.

THanks, Bruce


Olivier Thomann wrote:

> Le Wed, 12 May 2004 18:08:08 +0000 (UTC), bruce@coding-r-us.com (Bruce
> Schechter) a écrit :
> >Today, I started a new project that involves a class called SpellChecker,
> >which resides in its own file called SpellChecker.java. Eclipse gives me
> >an error: "The public type SpellChecker must be defined in its own file."
> Are you sure the case is the same for the file name and the public
> type?
> --
> Olivier
Re: error: public type XYZ must be defined in its own file [message #158476 is a reply to message #158460] Wed, 12 May 2004 15:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomannNO.ca.ibm.comSPAM

Le Wed, 12 May 2004 18:46:48 +0000 (UTC), bruce@coding-r-us.com (Bruce
Schechter) a écrit :
>Never-the-less, I would still appreciate help from someone on parts 2. and
>3. of my questions.
I don't see any solution for your second question. Most of the message
are good enough.

For 3, you select your class name or your method name and you press F3
(to get to the declaration) or F2 to get the corresponding javadoc.
--
Olivier
Re: error: public type XYZ must be defined in its own file [message #158483 is a reply to message #158443] Wed, 12 May 2004 15:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.rizzoweb.com

Bruce Schechter wrote:
> 2.) Within the Eclipse IDE, how can I request more detailed information
> about an error message? I see the same error message by hovering my mouse
> over the SpellChecker class declaration and also I see it in the "Tasks"
> pane. But I cannot find a mechanisme in either case to link to more info.

For compile errors, the message is all there is. I'm not sure what type
of info you'd want/expect. Care to give an example or elaborate?


> 3.) One broader question about the IDE... if I utilize a java system
> class name or method name in my code (like "ArrayList" or
> "myArrayList.size()" respectively) and I want to access documentation for
> that item, what is a quick way to get from the name in the code to the
> associated documentation?

Put your cursor on it and hit Shift-F2 to open external JavaDocs.
What I do most of the time is just to open the source for the class but
hitting F3 instead. The source contains all the JavaDocs plus the added
benefit of being able to see the code, which sometimes is more helpful.
Also note that if you let you pointer hover over a class or method name
in the editor, eventually a pop-up tool-tip will appear showing the
first part of the documentation.

Note that for any of these to work for the core Java APIs (java.lang.*,
etc), you have to be using a JDK instead of a JRE, and you have to tell
the configured JDK where to find its JavaDoc and/or source. See
Preferences > Java > Installed JREs > Edit...

HTH,
Eric
Re: error: public type XYZ must be defined in its own file [message #158492 is a reply to message #158483] Wed, 12 May 2004 16:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: bruce.coding-r-us.com

Eric Rizzo wrote:

> Bruce Schechter wrote:
> > 2.) Within the Eclipse IDE, how can I request more detailed information
> > about an error message? I see the same error message by hovering my mouse
> > over the SpellChecker class declaration and also I see it in the "Tasks"
> > pane. But I cannot find a mechanisme in either case to link to more info.

> For compile errors, the message is all there is. I'm not sure what type
> of info you'd want/expect. Care to give an example or elaborate?

Eric,

the reason I asked the question is based on my experience with C# within
Visual Studio.NET. When I get a compile error in vs.net, I get a brief
error message in a view similar to Eclipse's "tasks" view. However, in
vs.net the error will have an error number and will be "clickable" to
direct one to further explaination for the error. Typically, the
explaination will so a small code snippet showing a scenario that will
generate the error and possible fixes. In theory, this sounds great, but
in the real world my success rate of using these error messages may be
about 50% since ofter their example scenario is very different than my
code. But, never-the-less, it is really nice to have. I hope that helps
answer your question.

Please see one other question below...

> > 3.) One broader question about the IDE... if I utilize a java system
> > class name or method name in my code (like "ArrayList" or
> > "myArrayList.size()" respectively) and I want to access documentation for
> > that item, what is a quick way to get from the name in the code to the
> > associated documentation?

> Put your cursor on it and hit Shift-F2 to open external JavaDocs.
> What I do most of the time is just to open the source for the class but
> hitting F3 instead. The source contains all the JavaDocs plus the added
> benefit of being able to see the code, which sometimes is more helpful.
> Also note that if you let you pointer hover over a class or method name
> in the editor, eventually a pop-up tool-tip will appear showing the
> first part of the documentation.

> Note that for any of these to work for the core Java APIs (java.lang.*,
> etc), you have to be using a JDK instead of a JRE, and you have to tell
> the configured JDK where to find its JavaDoc and/or source. See
> Preferences > Java > Installed JREs > Edit...

> HTH,
> Eric

Eric,
Thanks for these tips. I didnt yet have the JDK javadoc location
specified as you explained above. It now works just fine.

But this begs yet another question for me. What if I want help on the
Java language itself (rather than on the java object model.) Let's say I
don't recall how to utilize the keyword "implements." Can I select it,
and then link somehow to documentation?

Sorry for all the newbie questions. I really appreciate the help.

Cheers, Bruce
Re: error: public type XYZ must be defined in its own file [message #158980 is a reply to message #158492] Mon, 17 May 2004 06:03 Go to previous message
Eclipse UserFriend
This is something we wanted to invest into a while ago, but never actually
addressed.
Typically an error message should provide a URL allowing to navigate from
the problem to some doc, think of JLS paragraph etc...

"Bruce Schechter" <bruce@coding-r-us.com> wrote in message
news:c7u2jc$o6k$1@eclipse.org...
> Eric Rizzo wrote:
>
> > Bruce Schechter wrote:
> > > 2.) Within the Eclipse IDE, how can I request more detailed
information
> > > about an error message? I see the same error message by hovering my
mouse
> > > over the SpellChecker class declaration and also I see it in the
"Tasks"
> > > pane. But I cannot find a mechanisme in either case to link to more
info.
>
> > For compile errors, the message is all there is. I'm not sure what type
> > of info you'd want/expect. Care to give an example or elaborate?
>
> Eric,
>
> the reason I asked the question is based on my experience with C# within
> Visual Studio.NET. When I get a compile error in vs.net, I get a brief
> error message in a view similar to Eclipse's "tasks" view. However, in
> vs.net the error will have an error number and will be "clickable" to
> direct one to further explaination for the error. Typically, the
> explaination will so a small code snippet showing a scenario that will
> generate the error and possible fixes. In theory, this sounds great, but
> in the real world my success rate of using these error messages may be
> about 50% since ofter their example scenario is very different than my
> code. But, never-the-less, it is really nice to have. I hope that helps
> answer your question.
>
> Please see one other question below...
>
> > > 3.) One broader question about the IDE... if I utilize a java system
> > > class name or method name in my code (like "ArrayList" or
> > > "myArrayList.size()" respectively) and I want to access documentation
for
> > > that item, what is a quick way to get from the name in the code to the
> > > associated documentation?
>
> > Put your cursor on it and hit Shift-F2 to open external JavaDocs.
> > What I do most of the time is just to open the source for the class but
> > hitting F3 instead. The source contains all the JavaDocs plus the added
> > benefit of being able to see the code, which sometimes is more helpful.
> > Also note that if you let you pointer hover over a class or method name
> > in the editor, eventually a pop-up tool-tip will appear showing the
> > first part of the documentation.
>
> > Note that for any of these to work for the core Java APIs (java.lang.*,
> > etc), you have to be using a JDK instead of a JRE, and you have to tell
> > the configured JDK where to find its JavaDoc and/or source. See
> > Preferences > Java > Installed JREs > Edit...
>
> > HTH,
> > Eric
>
> Eric,
> Thanks for these tips. I didnt yet have the JDK javadoc location
> specified as you explained above. It now works just fine.
>
> But this begs yet another question for me. What if I want help on the
> Java language itself (rather than on the java object model.) Let's say I
> don't recall how to utilize the keyword "implements." Can I select it,
> and then link somehow to documentation?
>
> Sorry for all the newbie questions. I really appreciate the help.
>
> Cheers, Bruce
>
>
Previous Topic:Query Regarding tomcat projects with ellipse
Next Topic:Problem with Cheetah04
Goto Forum:
  


Current Time: Sun Jun 08 07:07:16 EDT 2025

Powered by FUDForum. Page generated in 0.04642 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top