Add own Class to CLASSPATH [message #194971] |
Mon, 19 February 2007 10:42 |
Eclipse User |
|
|
|
Originally posted by: roland.kluge.gmx.de
Hello!
I have got a problem which makes me despair!!
I want to define an own class in a separate .java file, e.g. called
"Window.java"
Now I want a programm (PasswordCheck.java) to use this newly defined
class "Window"!
The recommended command for this is
import Window;
....
PasswordWindow = new Window();
....
etc.
I have to code provided in a tutorial, so this should work!
My problem is that I do not manage to make Eclipse use Window.java /
Window.class as an alternative CLASSPATH.
Can anybody give me advise how to deal with this problem???
Thank You in advance!!
Roland
|
|
|
Re: Add own Class to CLASSPATH [message #194980 is a reply to message #194971] |
Mon, 19 February 2007 11:15 |
Eclipse User |
|
|
|
Originally posted by: krzysztofHMMMMdaniel.gmail.com
Hi,
Are both classes in the same folder? If not, you can try move your new
class to the same folder as previous. This should help.
If not, please post here the structure of your project (from package
explorer view).
--
Chris
|
|
|
Re: Add own Class to CLASSPATH [message #194988 is a reply to message #194980] |
Mon, 19 February 2007 11:21 |
Eclipse User |
|
|
|
Originally posted by: roland.kluge.gmx.de
Thanks for your quick reply!
They are both in the same Folder, but I think this is not the problem...
In my opinion, Eclipse should know where to find this new class... And
that's my problem. How do I make Eclipse accept new classpath-files??
Roland
Krzysztof Daniel wrote:
> Hi,
>
> Are both classes in the same folder? If not, you can try move your new
> class to the same folder as previous. This should help.
>
> If not, please post here the structure of your project (from package
> explorer view).
>
> --
> Chris
|
|
|
Re: Add own Class to CLASSPATH [message #195005 is a reply to message #194988] |
Mon, 19 February 2007 11:57 |
Eclipse User |
|
|
|
Originally posted by: krzysztofHMMMMdaniel.gmail.com
Then please remove
import Window;
line.
When classes are in the same folder(package) it is not required and it
may confuse eclipse.
--
Chris
|
|
|
Re: Add own Class to CLASSPATH [message #195013 is a reply to message #195005] |
Mon, 19 February 2007 12:46 |
Eclipse User |
|
|
|
Originally posted by: roland.kluge.gmx.de
Thanks a lot!!! It finally worked!
Do you know how to compile .java's with the Java-Compiler in the JDK (I
have vers 1.6.0).
Do you have an idea why one could use the "import"-methode to get this
class - as it was written in my tutorial??
I also tried it with the Java-Compiler in the JDK and it worked as well
*without* the import... (with import I got an error message...)
So I think in this context it does not make any sense!
Roland
Krzysztof Daniel wrote:
> Then please remove
> import Window;
> line.
>
> When classes are in the same folder(package) it is not required and it
> may confuse eclipse.
>
> --
> Chris
|
|
|
|
Re: Add own Class to CLASSPATH [message #195025 is a reply to message #195020] |
Mon, 19 February 2007 14:03 |
Eclipse User |
|
|
|
Originally posted by: roland.kluge.gmx.de
OK, I think this is a good idea... Thank You!
Roland
Krzysztof Daniel wrote:
> I think you should now contact the author of the tutorial and explain
> the whole situation to him ;).
>
> Regards,
> Chris
|
|
|
Re: Add own Class to CLASSPATH [message #195055 is a reply to message #195013] |
Mon, 19 February 2007 21:52 |
Eclipse User |
|
|
|
Originally posted by: dtoland.email.uophx.edu
What was the error message you saw? That could be a clue to the problem.
Incidentally, when you compile with eclipse, you are really compiling with the
Java compiler in the JDK. Eclipse is simply keeping track of what options to pass to
the compiler, javac.
--
Dave Toland
dave.toland@verizon.net
"Roland Kluge" <roland.kluge@gmx.de> wrote in message news:erc671$v8i$1@utils.eclipse.org...
| Thanks a lot!!! It finally worked!
|
| Do you know how to compile .java's with the Java-Compiler in the JDK (I
| have vers 1.6.0).
| Do you have an idea why one could use the "import"-methode to get this
| class - as it was written in my tutorial??
| I also tried it with the Java-Compiler in the JDK and it worked as well
| *without* the import... (with import I got an error message...)
| So I think in this context it does not make any sense!
|
| Roland
|
| Krzysztof Daniel wrote:
| > Then please remove
| > import Window;
| > line.
| >
| > When classes are in the same folder(package) it is not required and it
| > may confuse eclipse.
| >
| > --
| > Chris
|
|
|
Re: Add own Class to CLASSPATH [message #195063 is a reply to message #195055] |
Mon, 19 February 2007 22:09 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Dave,
I don't think your comment about the JDK being used is true. I'm quite
sure that Eclipse has its own incremental compiler.
With regard to this whole thread about "import ABC;" I don't think that
can ever be a valid import because classes from the default package can
only be used in other classes from the default package, in which case no
import is needed and since they can't be imported into any other
package, you can't ever have "import Abc;" without a qualified name that
includes at least one package segment.
Dave Toland wrote:
> What was the error message you saw? That could be a clue to the problem.
>
> Incidentally, when you compile with eclipse, you are really compiling with the
> Java compiler in the JDK. Eclipse is simply keeping track of what options to pass to
> the compiler, javac.
>
>
|
|
|
Re: Add own Class to CLASSPATH [message #195080 is a reply to message #195063] |
Tue, 20 February 2007 00:25 |
Eclipse User |
|
|
|
Originally posted by: eclipse5.rizzoweb.com
Ed Merks wrote:
> Dave,
>
> I don't think your comment about the JDK being used is true. I'm quite
> sure that Eclipse has its own incremental compiler.
>
> With regard to this whole thread about "import ABC;" I don't think that
> can ever be a valid import because classes from the default package can
> only be used in other classes from the default package, in which case no
> import is needed and since they can't be imported into any other
> package, you can't ever have "import Abc;" without a qualified name that
> includes at least one package segment.
I just want to confirm 100% Ed's comments. Eclipse does NOT use the JDK
compiler, and you can NOT import classes from the default package as of
recent Java versions (that is a Java restriction, not an Eclipse one).
Eric
|
|
|
Re: Add own Class to CLASSPATH [message #195088 is a reply to message #195080] |
Tue, 20 February 2007 01:26 |
Eclipse User |
|
|
|
Originally posted by: dtoland.email.uophx.edu
I stand corrected, then. Thank you for straightening me out on that. I find it
surprising, and guess that it must be a bit of a maintenance headache, but would
certainly have advantages.
--
Dave Toland
dave.toland@verizon.net
"Eric Rizzo" <eclipse5@rizzoweb.com> wrote in message news:erdf5q$q03$1@utils.eclipse.org...
| Ed Merks wrote:
| > Dave,
| >
| > I don't think your comment about the JDK being used is true. I'm quite
| > sure that Eclipse has its own incremental compiler.
| >
| > With regard to this whole thread about "import ABC;" I don't think that
| > can ever be a valid import because classes from the default package can
| > only be used in other classes from the default package, in which case no
| > import is needed and since they can't be imported into any other
| > package, you can't ever have "import Abc;" without a qualified name that
| > includes at least one package segment.
|
| I just want to confirm 100% Ed's comments. Eclipse does NOT use the JDK
| compiler, and you can NOT import classes from the default package as of
| recent Java versions (that is a Java restriction, not an Eclipse one).
|
| Eric
|
|
|
|
Re: Add own Class to CLASSPATH [message #195128 is a reply to message #195105] |
Tue, 20 February 2007 10:47 |
Eclipse User |
|
|
|
Originally posted by: roland.kluge.gmx.de
Yes, you're right! Even the JDK Compiler works without using the
import-syntax as I already mentioned!
Now Eclipse and me are friends again ;-)!
Another clue therefore that Eclipse is not using the Java-Compiler from
the JDK is that you simply need the JRE to install Eclipse (or to run
it!) and this package does not include any compiler!
Roland
|
|
|
Re: Add own Class to CLASSPATH [message #195287 is a reply to message #195105] |
Wed, 21 February 2007 01:44 |
Eclipse User |
|
|
|
Originally posted by: dtoland.email.uophx.edu
Yes, thank you, I do know that.
--
Dave Toland
dave.toland@verizon.net
"GinKGO" <ginkgo_w@yahoo.com.cn> wrote in message news:rnukt2top8e9ohsamktdfvse4hj9ksni2v@4ax.com...
| On Mon, 19 Feb 2007 20:26:07 -0500, "Dave Toland"
| <dtoland@email.uophx.edu> wrote:
|
| >I stand corrected, then. Thank you for straightening me out on that. I find it
| >surprising, and guess that it must be a bit of a maintenance headache, but would
| >certainly have advantages.
|
| I think you should know the classpath that eclipse used is not the
| classpath that you defined with "CLASSPATH" in your system path
| variable.
|
| Eclipse use his own management. if you explore your project folder,
| you will find a .classpath file. It is a xml file define the classpath
| that eclipse used.
|
| In [Window]->[Preferences]->[java]->[build path] or [installed jre].
|
| when you need Window.class, you should add this by using [context
| menu] -> [build path].
|
| BTW. if you run your program out the eclipse you should add the
| Window.class to your system CLASSPATH.
|
|
|
Powered by
FUDForum. Page generated in 0.09732 seconds