Home » Newcomers » Newcomers » Java compile by hand works - eclipse is all confused... And, a missing FAQ.
Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259473] |
Fri, 27 June 2008 20:37  |
Eclipse User |
|
|
|
Originally posted by: rtroy.sciencetools.com
Hello All,
I'm excited by what I see with Eclipse but am having some trouble getting
rolling. I've been using Java since 1997, and was formerly a Visual Cafe
and JBuilder user, but am happy to move "into the modern era." Thanks in
advance for your help. I've got two problems. One of them is a basic
compile configuration issue - I already have good code but it won't build.
The other has to do with command-line applications. ...I figure that with
both issues, either I'm overlooking something right in front of my nose,
or my use is so a-typical as to be "new" to the Eclipse environment.
It's worth pointing out that I started with the tutorial, Hello World. It
didn't help me understand either issue.
As background for both issues; I've got an app that is rather
sophisticated and has two fundamental parts: an API library and a bunch
of API code, most notably a GUI with oh, some eighty frames or so. There
are no libraries other than straight Sun-provided Java and six RDBMS
vendor JDBC liraries. One thing this code has to do is overcome a lot of
the short comings of Java, such as file permissions manipulation, dealing
with SetUID and so on - probably familliar to many of you who also code in
C. So, it's not supposed to be launched by Java but rather by a C wrapper
that does all the UID stuff.
I'm guessing that Eclipse doesn't provide me any way to test the
command-line stuff as I've been through all the setup screens, though
under Jbuilder I was able to get run-time debugging, break-points and
other such working by substituting my C program for javaw.exe (on
Windows). I don't even see how I can provide command line arguments and
command-line properties, though in my research I did find a reference to a
2005 comment about
http://www.eclipsefaq.org/ FAQ 59, but I haven't been able to actually
find that document/text. So, there's the first issue; Please advise how I
can get at command-line features.
The second issue is that I can't get my code to compile with Eclipse,
though a simple one-liner works great from the command line.
I'm speculating, but perhaps it's how my application differs from other
more common methods of doing things. The Application and API have
something different about them in that one of the jobs is to compile java
on the fly and/or absorb java class files, and the solution heretofore has
been to use an open directory wherein things can be deposited as needed
and picked up by the application. This means that the API and application
ARE NOT bundled into jar files - and really can't be, at least not easily.
I _think_ this is part of where Eclipse gets in trouble. But, I may well
be wrong.
In my attempts thus far, I decided to leave the API as a library found in
an open directory (NOT a jar) and create a new Java project for the GUI as
it is its own 'package'. Into my new Eclipse Java Project, I imported the
GUI's source using General, -> File System. OK, only 3685 "errors!"
Alright, it needs to know about the API, fair enough... Project ->
Properties -> Java Build Path -> Libraries -> Add External Class Folder ->
<lib_directory>. Down to 84 "errors" - yeah! That's one per frame - each
of which has its own file; "The declared package <package name> does not
match the expected package."
A mouse-over of the primary package statement gave me two choices - remove
it from the package or, "Move <frame.java> to <package>." When I tried
that, the error count increased to 3320! Obviously, whatever that does
isn't helping. But, I didn't try all 83 files... Is this my error?
I fiddled around at great length with Project -> Properties, etc, as
described above, and never figured out how to tell it it's in its own
package. Considering this works great from a simple javac from the command
line, this is rather frustrating.
Thanks again for your help,
Richard
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259482 is a reply to message #259473] |
Fri, 27 June 2008 21:30   |
Eclipse User |
|
|
|
Originally posted by: codeslave.ca.ibm.com
First off, Eclipse does a lot more than just javac.exe & java.exe, so
there's often more to do to set things up. But you benefit from getting
a lot more out of it, like code completion, debugging, and so forth.
So, while it can be frustrating at first, it's worth it. :)
Here's a few FAQ entries you might like:
http://wiki.eclipse.org/FAQ_How_do_I_find_out_the_command-li ne_arguments_of_a_launched_program%3F
http://wiki.eclipse.org/FAQ_Why_doesn%27t_my_program_start_w hen_I_click_the_Run_button%3F
http://wiki.eclipse.org/FAQ_What_is_a_launch_configuration%3 F
http://wiki.eclipse.org/index.php/Eclipse_FAQs#Java_Developm ent_in_Eclipse
http://wiki.eclipse.org/index.php/IRC_FAQ#How_do_I_export_a_ launch_configuration.3F
http://wiki.eclipse.org/index.php/IRC_FAQ#I_am_working_on_a_ project_and_doing_something_or_other_does_not_work._Where_sh ould_I_start.3F
http://wiki.eclipse.org/FAQ_How_do_I_add_an_extra_library_to _my_project%27s_classpath%3F
As to packages... all you need to do is ensure that
projectFolder\src\org\foo\somepackage\Foobar.java declares itself to be
in package org.foo.somepackage, and the errors should (hopefully) go away.
Be sure your workspace is set to build automatically (Project > Build
automatically), and force it to clean itself (Project > Clean...) once
in a while.
Nick
Richard wrote:
>
> Hello All,
>
> I'm excited by what I see with Eclipse but am having some trouble
> getting rolling. I've been using Java since 1997, and was formerly a
> Visual Cafe and JBuilder user, but am happy to move "into the modern
> era." Thanks in advance for your help. I've got two problems. One of
> them is a basic compile configuration issue - I already have good code
> but it won't build. The other has to do with command-line applications.
> ...I figure that with both issues, either I'm overlooking something
> right in front of my nose, or my use is so a-typical as to be "new" to
> the Eclipse environment.
>
> It's worth pointing out that I started with the tutorial, Hello World.
> It didn't help me understand either issue.
>
> As background for both issues; I've got an app that is rather
> sophisticated and has two fundamental parts: an API library and a bunch
> of API code, most notably a GUI with oh, some eighty frames or so. There
> are no libraries other than straight Sun-provided Java and six RDBMS
> vendor JDBC liraries. One thing this code has to do is overcome a lot of
> the short comings of Java, such as file permissions manipulation,
> dealing with SetUID and so on - probably familliar to many of you who
> also code in C. So, it's not supposed to be launched by Java but rather
> by a C wrapper that does all the UID stuff.
>
> I'm guessing that Eclipse doesn't provide me any way to test the
> command-line stuff as I've been through all the setup screens, though
> under Jbuilder I was able to get run-time debugging, break-points and
> other such working by substituting my C program for javaw.exe (on
> Windows). I don't even see how I can provide command line arguments and
> command-line properties, though in my research I did find a reference to
> a 2005 comment about http://www.eclipsefaq.org/ FAQ 59, but I haven't
> been able to actually find that document/text. So, there's the first
> issue; Please advise how I can get at command-line features.
>
> The second issue is that I can't get my code to compile with Eclipse,
> though a simple one-liner works great from the command line.
>
> I'm speculating, but perhaps it's how my application differs from other
> more common methods of doing things. The Application and API have
> something different about them in that one of the jobs is to compile
> java on the fly and/or absorb java class files, and the solution
> heretofore has been to use an open directory wherein things can be
> deposited as needed and picked up by the application. This means that
> the API and application ARE NOT bundled into jar files - and really
> can't be, at least not easily. I _think_ this is part of where Eclipse
> gets in trouble. But, I may well be wrong.
>
> In my attempts thus far, I decided to leave the API as a library found
> in an open directory (NOT a jar) and create a new Java project for the
> GUI as it is its own 'package'. Into my new Eclipse Java Project, I
> imported the GUI's source using General, -> File System. OK, only 3685
> "errors!"
>
> Alright, it needs to know about the API, fair enough... Project ->
> Properties -> Java Build Path -> Libraries -> Add External Class Folder
> -> <lib_directory>. Down to 84 "errors" - yeah! That's one per frame -
> each of which has its own file; "The declared package <package name>
> does not match the expected package."
> A mouse-over of the primary package statement gave me two choices -
> remove it from the package or, "Move <frame.java> to <package>." When I
> tried that, the error count increased to 3320! Obviously, whatever that
> does isn't helping. But, I didn't try all 83 files... Is this my error?
>
> I fiddled around at great length with Project -> Properties, etc, as
> described above, and never figured out how to tell it it's in its own
> package. Considering this works great from a simple javac from the
> command line, this is rather frustrating.
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259485 is a reply to message #259473] |
Fri, 27 June 2008 21:41   |
Eclipse User |
|
|
|
Originally posted by: rtroy.sciencetools.com
OK, PARTIALLY solved.
I found I could create a new package, so I got this idea to create a new
package called the one I already had. I fought with the import mechanism
for a while, and I had already noted the directory structure check box.
So, I tried a few dozen permutations until I got it to work.
THIS SHOULD BE VASTLY EASIER, GUYS!
First, create your new (old) package. Then put your about to be imported
files into a subdirectory of the same name as the package. Then, point the
importer to the parent of this and check the check box asking for it.
This exercise pointed out a number of deficiencies that _should_ be easy
to fix. For one, it is an artificial requirement that the files of a
package belong in their own subdirectory and at the very least, the code
that does the importing should check for this condition and break out
subdirectories as needed. Lots of ways to handle this including having a
special "import package" option, esp since there are all those others
already. Another deficiency is that there's no "add file,", one file at a
time (as opposed to an import). And, there's no easy resynchronization
with the file system. (I'd deleted the files manually and expected Eclipse
to keep up with me - it wouldn't!)
I guess I'll have to see if I can contribute something to the code
development! -smile-
Meanwhile, the command-line issues still remain: How can I launch my java
applications with a different executable and still use the trace/debugging
tools? And, probably answered along the way to answer that, how can I pass
command line arguments?
THANKS GUYS - looks like a great IDE...
Richard
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259489 is a reply to message #259482] |
Fri, 27 June 2008 21:46   |
Eclipse User |
|
|
|
Originally posted by: rtroy.sciencetools.com
Nick Boldt wrote:
> First off, Eclipse does a lot more than just javac.exe & java.exe, so
> there's often more to do to set things up. But you benefit from getting
> a lot more out of it, like code completion, debugging, and so forth.
> So, while it can be frustrating at first, it's worth it. :)
> Here's a few FAQ entries you might like:
>
http://wiki.eclipse.org/FAQ_How_do_I_find_out_the_command-li ne_arguments_of_a_launched_program%3F
>
http://wiki.eclipse.org/FAQ_Why_doesn%27t_my_program_start_w hen_I_click_the_Run_button%3F
> http://wiki.eclipse.org/FAQ_What_is_a_launch_configuration%3 F
> http://wiki.eclipse.org/index.php/Eclipse_FAQs#Java_Developm ent_in_Eclipse
>
http://wiki.eclipse.org/index.php/IRC_FAQ#How_do_I_export_a_ launch_configuration.3F
>
http://wiki.eclipse.org/index.php/IRC_FAQ#I_am_working_on_a_ project_and_doing_something_or_other_does_not_work._Where_sh ould_I_start.3F
>
http://wiki.eclipse.org/FAQ_How_do_I_add_an_extra_library_to _my_project%27s_classpath%3F
> As to packages... all you need to do is ensure that
> projectFoldersrcorgfoosomepackageFoobar.java declares itself to be
> in package org.foo.somepackage, and the errors should (hopefully) go away.
> Be sure your workspace is set to build automatically (Project > Build
> automatically), and force it to clean itself (Project > Clean...) once
> in a while.
> Nick
THANKS NICK, that was fast!
Persistence had paid off somewhat - I found out about the directory
hierarchy, but it _is_ an artificial requirement: Eclipse may require it
but Java does not, of course.
Thanks also for the pointers to these URLs - the FAQs. I found some but
you've pointed me to the ones I really need. ...I _try_ not to be "needy!"
-smile-
Regards,
Richard
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259493 is a reply to message #259489] |
Sat, 28 June 2008 00:28   |
Eclipse User |
|
|
|
Originally posted by: codeslave.ca.ibm.com
> Persistence had paid off somewhat - I found out about the directory
> hierarchy, but it _is_ an artificial requirement: Eclipse may require it
> but Java does not, of course.
Right, but once you get past POJOs (plain ol' java objects) and into
OSGi bundles/plugins, there's a method to the madness and the extra pain
pays off. You can even use Eclipse's PDE to convert from a java project
to a plugin project -- IIRC you can right-click a project and select PDE
Tools > Convert Projects to Plugin Projects. Might be overkill for your
needs, but it's worth mentioning.
> Thanks also for the pointers to these URLs - the FAQs. I found some but
> you've pointed me to the ones I really need. ...I _try_ not to be
> "needy!" -smile-
Don't worry about it -- that's what this newsgroup is for. BTW, there's
also the IRC channel #eclipse on freenode.net, for more interactive
support. If you can't do IRC at work due to firewall constraints,
there's mibbit.com which lets you connect with nothing more than your
browser.
See also http://wiki.eclipse.org/IRC and http://wiki.eclipse.org/IRC_FAQ.
Nick
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259579 is a reply to message #259485] |
Mon, 30 June 2008 05:57   |
Eclipse User |
|
|
|
Originally posted by: 4cs6fcg02.sneakemail.com
This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enig411B70C2174B4AC8C63B4B6C
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Richard schreef:
>=20
>=20
> OK, PARTIALLY solved.
>=20
> I found I could create a new package, so I got this idea to create a ne=
w=20
> package called the one I already had. I fought with the import mechanis=
m=20
> for a while, and I had already noted the directory structure check box.=
=20
> So, I tried a few dozen permutations until I got it to work.
>=20
> THIS SHOULD BE VASTLY EASIER, GUYS!
>=20
> First, create your new (old) package. Then put your about to be importe=
d=20
> files into a subdirectory of the same name as the package. Then, point =
> the importer to the parent of this and check the check box asking for i=
t.
>=20
> This exercise pointed out a number of deficiencies that _should_ be eas=
y=20
> to fix. For one, it is an artificial requirement that the files of a=20
> package belong in their own subdirectory and at the very least, the cod=
e=20
> that does the importing should check for this condition and break out=20
> subdirectories as needed. Lots of ways to handle this including having =
a=20
> special "import package" option, esp since there are all those others=20
> already. Another deficiency is that there's no "add file,", one file at=
=20
> a time (as opposed to an import). And, there's no easy resynchronizatio=
n=20
> with the file system. (I'd deleted the files manually and expected=20
> Eclipse to keep up with me - it wouldn't!)
>=20
> I guess I'll have to see if I can contribute something to the code=20
> development! -smile-
You can start by filing an RFE: https://bugs.eclipse.org/bugs/
Cheers, H.
--=20
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
--------------enig411B70C2174B4AC8C63B4B6C
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAkhoriMACgkQe+7xMGD3itQ7tgCfdkAHB0a2UstEwgsJoE0c 6qM3
oMIAniHc0xdH6svdOoBodZlr6bgDl5YG
=jTSB
-----END PGP SIGNATURE-----
--------------enig411B70C2174B4AC8C63B4B6C--
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259606 is a reply to message #259493] |
Mon, 30 June 2008 09:53   |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
Nick Boldt wrote:
>
>> Persistence had paid off somewhat - I found out about the directory
>> hierarchy, but it _is_ an artificial requirement: Eclipse may require
>> it but Java does not, of course.
>
> Right, but once you get past POJOs (plain ol' java objects) and into
> OSGi bundles/plugins, there's a method to the madness and the extra pain
> pays off. You can even use Eclipse's PDE to convert from a java project
> to a plugin project -- IIRC you can right-click a project and select PDE
> Tools > Convert Projects to Plugin Projects. Might be overkill for your
> needs, but it's worth mentioning.
It's not just for OSGi or plugin projects that it makes sense. The "all
files in one directory" strategy falls apart as soon as you want/need
two classes with the same name but in different packages. And, honestly,
it is a totally disorganized way of storing code. I'm surprised there
are projects of real size out there that still do it that way.
Anyway, that particular aspect of Eclipse is not ever likely to change,
so I'd suggest just get used to it and spend your efforts elsewhere if
you're interested in entering or coding enhancements :-)
>> Thanks also for the pointers to these URLs - the FAQs. I found some
>> but you've pointed me to the ones I really need. ...I _try_ not to be
>> "needy!" -smile-
>
> Don't worry about it -- that's what this newsgroup is for. BTW, there's
> also the IRC channel #eclipse on freenode.net, for more interactive
> support. If you can't do IRC at work due to firewall constraints,
> there's mibbit.com which lets you connect with nothing more than your
> browser.
Thanks for the mibbit suggestion, Nick! I've been looking for an IRC
solution at work for almost a year, and mibbit looks good. I just wish I
could get it to use a pop-up mode or some kind of notification of
channel activity when the browser window is behind others.
Eric
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259610 is a reply to message #259485] |
Mon, 30 June 2008 10:09   |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
Richard wrote:
>
>
> OK, PARTIALLY solved.
>
> I found I could create a new package, so I got this idea to create a new
> package called the one I already had. I fought with the import mechanism
> for a while, and I had already noted the directory structure check box.
> So, I tried a few dozen permutations until I got it to work.
>
> THIS SHOULD BE VASTLY EASIER, GUYS!
>
> First, create your new (old) package. Then put your about to be imported
> files into a subdirectory of the same name as the package. Then, point
> the importer to the parent of this and check the check box asking for it.
Other than having your .java files in a directory structure instead of
all dumped into one directory, it's not clear what could be easier. Can
you provide more details? For example, a sample layout of your
project(s) and the exact things you did in Eclipse...
>
> This exercise pointed out a number of deficiencies that _should_ be easy
> to fix. For one, it is an artificial requirement that the files of a
> package belong in their own subdirectory and at the very least, the code
> that does the importing should check for this condition and break out
> subdirectories as needed. Lots of ways to handle this including having a
> special "import package" option, esp since there are all those others
> already. Another deficiency is that there's no "add file,", one file at
> a time (as opposed to an import). And, there's no easy resynchronization
> with the file system. (I'd deleted the files manually and expected
> Eclipse to keep up with me - it wouldn't!)
If you've imported .java files whose directory structure does not match
the packages they declare, it is not overly difficult to correct things,
depending on how many files and different packages there are. When I've
had to do that in the past for small number of files, I just go into
each one and use Quick Fix to move it to the correct structure. In
Eclipse 3.3, invoke Quick Fix by putting the cursor on the error marker
in the package declaration and hit Ctrl+1; in Eclipse 3.4, the quick fix
shows as a hyperlink in the hover/popup when you hold the mouse over the
error marker in code.
For larger sets of files that need to be all moved to the same package,
you can select the files, right-click, and choose Refactor > Move... to
put them in the right place.
F5 or Right-click > Refresh in Eclipse will force it to re-read the file
system.
By the way, you said you did a Hello World tutorial; but even more
helpful to your situation might be the Project Configuration tutorial.
Hope this helps,
Eric
|
|
|
Re: Java compile by hand works - eclipse is all confused... And, a missing FAQ. [message #259614 is a reply to message #259485] |
Mon, 30 June 2008 10:12  |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
Richard wrote:
>
>
> OK, PARTIALLY solved.
>
> I found I could create a new package, so I got this idea to create a new
> package called the one I already had. I fought with the import mechanism
> for a while, and I had already noted the directory structure check box.
> So, I tried a few dozen permutations until I got it to work.
>
> THIS SHOULD BE VASTLY EASIER, GUYS!
>
> First, create your new (old) package. Then put your about to be imported
> files into a subdirectory of the same name as the package. Then, point
> the importer to the parent of this and check the check box asking for it.
>
> This exercise pointed out a number of deficiencies that _should_ be easy
> to fix. For one, it is an artificial requirement that the files of a
> package belong in their own subdirectory and at the very least, the code
> that does the importing should check for this condition and break out
> subdirectories as needed. Lots of ways to handle this including having a
> special "import package" option, esp since there are all those others
> already.
If you have specific ideas for how to improve the import UI, feel free
to enter enhancement requests in Bugzilla
(https://bugs.eclipse.org/bugs). Because this is open-source, code
contributions are highly encouraged and obviously increase the
likelihood of your request getting addressed.
Eric
|
|
|
Goto Forum:
Current Time: Mon May 12 19:06:54 EDT 2025
Powered by FUDForum. Page generated in 0.07910 seconds
|