Skip to main content



      Home
Home » Newcomers » Newcomers » How best to use with Java Packages?
How best to use with Java Packages? [message #258053] Tue, 10 June 2008 15:58 Go to next message
Eclipse UserFriend
Hello,

I have been happily using Eclipse for a few years but I think I setup my
projects in a "Brute Force" manner. I played around until I got something
to work and did cut and paste to move my .java files to my configuration
management folders from source folders in my projects area.

I am installing version 3.3.2 and decided to use the tool more wisely.
I've played with it for a couple days and remain frustrated.

Let me state my situation and objectives.

Situation:
I am developing 2 Java packages [pk_1 and pk_2] designed for use in Java
Stand=Alone Apps.
Ideally, the code resides in the following folders:
C:/com/pk_1/
C:/com/pk_2/
I also have a folder that contains the .jar files used by one or both of
these packages:
C:/classLibraries/

Objective:
Use Eclipse to develop and test these packages:

What I have been trying to figure out is how to do the following:

1) Create a development project for each Java Package to reference the
above folders and produce a pk_1.jar and pk_1.jar file.

2) Create test projects that use the pk_1.jar and pk_2.jar files as
follows:
a) Project Test pk_1: Stand-Alone program using pk_1.jar.
b) Project Test pk_2: Stand-Alone program using pk_2.jar.
c) Project Test pk_1_2: Stand-Alone program using pk_1.jar and
pk_2.jar.
Note: the .java class used in the above projects would be hosted in the
Eclipse 3.3.2 workspace holder.

I have come close to the setting up one of the packages but the
compilation fails on my "import com.pk_1" statement saying the package was
not a expected.

I'm going around in circles and need some advise.

Regards,
Jim...
Re: How best to use with Java Packages? [message #258058 is a reply to message #258053] Tue, 10 June 2008 16:24 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: wegener.cboenospam.com

"Jim Crowell" <jimCrowell@EMail.com> wrote in message
news:2657829e438a94480bf1185d9968d02a$1@www.eclipse.org...
> Hello,
>
> I have been happily using Eclipse for a few years but I think I setup my
> projects in a "Brute Force" manner. I played around until I got something
> to work and did cut and paste to move my .java files to my configuration
> management folders from source folders in my projects area.
>
> I am installing version 3.3.2 and decided to use the tool more wisely.
> I've played with it for a couple days and remain frustrated.
>
> Let me state my situation and objectives.
>
> Situation:
> I am developing 2 Java packages [pk_1 and pk_2] designed for use in Java
> Stand=Alone Apps.
> Ideally, the code resides in the following folders:
> C:/com/pk_1/
> C:/com/pk_2/
> I also have a folder that contains the .jar files used by one or both of
> these packages:
> C:/classLibraries/
>
> Objective:
> Use Eclipse to develop and test these packages:
>
> What I have been trying to figure out is how to do the following:
>
> 1) Create a development project for each Java Package to reference the
> above folders and produce a pk_1.jar and pk_1.jar file.
>
> 2) Create test projects that use the pk_1.jar and pk_2.jar files as
> follows:
> a) Project Test pk_1: Stand-Alone program using pk_1.jar.
> b) Project Test pk_2: Stand-Alone program using pk_2.jar.
> c) Project Test pk_1_2: Stand-Alone program using pk_1.jar and
> pk_2.jar.
> Note: the .java class used in the above projects would be hosted in the
> Eclipse 3.3.2 workspace holder.
>
> I have come close to the setting up one of the packages but the
> compilation fails on my "import com.pk_1" statement saying the package was
> not a expected.
>
> I'm going around in circles and need some advise.
>
> Regards,
> Jim...
>

Check out the project configuration tutorial in the Java Development User
Guide in Help Contents. It is in the Getting Started section. The tutorial
discusses several types of projects and how to set them up depending on your
preferences.
Re: How best to use with Java Packages? [message #258177 is a reply to message #258058] Wed, 11 June 2008 15:07 Go to previous messageGo to next message
Eclipse UserFriend
Dave Wegener responded:
> Check out the project configuration tutorial in the Java Development User
> Guide in Help Contents. It is in the Getting Started section. The tutorial
> discusses several types of projects and how to set them up depending on your
> preferences.

Thanks Dave.
I have been there before but the resultant project gave me errors about an
unexpected Java package name.

I did not use it as directed however. I was trying to use the C:/com/pk_1/
folder as my source.

It looks to me like I can not do as I wanted.
I have to put my source code in a c:/pk_1/source/com/pk_1/ folder to
produce a .jar where the end user will use the following desired import
statement:
import com.pk_1.*;

This is OK in that I still have a folder outside the Eclipse Project
workspace that contains my Latest Java code for cm purposes.

In all my Eclipse setup reading, I never saw anything telling me how to
setup for a "com.packageName" development.

Several years ago, before using Eclipse, I used EMacs and setup packages
in c:/com/packageName folders and I always thought there must be away to
do the same with Eclipse.

Just stubborn I guess!

Thanks for the help,
Jim...
Re: How best to use with Java Packages? [message #258231 is a reply to message #258177] Thu, 12 June 2008 04:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: 4cs6fcg02.sneakemail.com

This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
--------------enigC57737F119DC36F01E2114C9
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Jim Crowell schreef:
> Dave Wegener responded:
>> Check out the project configuration tutorial in the Java Development U=
ser
>> Guide in Help Contents. It is in the Getting Started section. The=20
>> tutorial
>> discusses several types of projects and how to set them up depending=20
>> on your
>> preferences.
>=20
> Thanks Dave.
> I have been there before but the resultant project gave me errors about=
=20
> an unexpected Java package name.
>=20
> I did not use it as directed however. I was trying to use the=20
> C:/com/pk_1/ folder as my source.
>=20
> It looks to me like I can not do as I wanted.
> I have to put my source code in a c:/pk_1/source/com/pk_1/ folder to=20
> produce a .jar where the end user will use the following desired import=
=20
> statement:
> import com.pk_1.*;
>=20
> This is OK in that I still have a folder outside the Eclipse Project=20
> workspace that contains my Latest Java code for cm purposes.
>=20
> In all my Eclipse setup reading, I never saw anything telling me how to=
=20
> setup for a "com.packageName" development.
>=20
> Several years ago, before using Eclipse, I used EMacs and setup package=
s=20
> in c:/com/packageName folders and I always thought there must be away t=
o=20
> do the same with Eclipse.
>=20
> Just stubborn I guess!

When making a new Java project, Eclipse 3.3 will ask you where to put=20
it. You can take C: as a location although I would not recommend it=20
(this is what you are doing now: your Java setup is directly under C:,=20
you have to consider the com/ directory as part of the filename, sort=20
of). I=E2=80=99d recommend you make it C:/workspace or something.

Then, if you use the new class wizard, and give as package=20
com.packageName or class Test, Eclipse will automatically create the=20
directories com/packageName and put a file called Test.java there.

You can then, once you have the new project, import from existing=20
sources; choose the folder C: and check the com/ directory. That should =

do it.

Provided, of course, that your classes in com/pk_1/ all have a=20
declaration =E2=80=98package com.pk_1=E2=80=99.

Note that in the project properties, you can reference other Java=20
projects, which means that for example for the test projects, you don=E2=80=
=99t=20
need to put pk_1.jar in the classpath, but you can refer to the classes=20
directly. Nothing prevents you from including the jar, though.

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


--------------enigC57737F119DC36F01E2114C9
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.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iD8DBQFIUNkze+7xMGD3itQRAtZhAJ9ymLZR6Fo0ib6JnGOC2Nc0LpwiMACe IfAH
zP2iwruqx+9CIVRq+fubFdc=
=HxRS
-----END PGP SIGNATURE-----

--------------enigC57737F119DC36F01E2114C9--
Re: How best to use with Java Packages? [message #258243 is a reply to message #258231] Thu, 12 June 2008 04:58 Go to previous message
Eclipse UserFriend
Hendrik Maryns wrote:
> Jim Crowell schreef:
>> Dave Wegener responded:
>>> Check out the project configuration tutorial in the Java Development
>>> User
>>> Guide in Help Contents. It is in the Getting Started section. The
>>> tutorial
>>> discusses several types of projects and how to set them up depending
>>> on your
>>> preferences.
>>
>> Thanks Dave.
>> I have been there before but the resultant project gave me errors
>> about an unexpected Java package name.
>>
>> I did not use it as directed however. I was trying to use the
>> C:/com/pk_1/ folder as my source.
>>
>> It looks to me like I can not do as I wanted.
>> I have to put my source code in a c:/pk_1/source/com/pk_1/ folder to
>> produce a .jar where the end user will use the following desired
>> import statement:
>> import com.pk_1.*;
>>
>> This is OK in that I still have a folder outside the Eclipse Project
>> workspace that contains my Latest Java code for cm purposes.
>>
>> In all my Eclipse setup reading, I never saw anything telling me how
>> to setup for a "com.packageName" development.
>>
>> Several years ago, before using Eclipse, I used EMacs and setup
>> packages in c:/com/packageName folders and I always thought there
>> must be away to do the same with Eclipse.
>>
>> Just stubborn I guess!
>
> When making a new Java project, Eclipse 3.3 will ask you where to put
> it. You can take C: as a location
I doubt this works as this would overlap with the workspace location.
> although I would not recommend it (this is what you are doing now:
> your Java setup is directly under C:, you have to consider the com/
> directory as part of the filename, sort of). I’d recommend you make
> it C:/workspace or something.
Or simply move your source into its own folder, e.g. c:\source. Then you
can have your eclipse workspace anywhere on C:, create a Java project
and then add a source folder that links to c:\source.

Dani
>
> Then, if you use the new class wizard, and give as package
> com.packageName or class Test, Eclipse will automatically create the
> directories com/packageName and put a file called Test.java there.
>
> You can then, once you have the new project, import from existing
> sources; choose the folder C: and check the com/ directory. That
> should do it.
>
> Provided, of course, that your classes in com/pk_1/ all have a
> declaration ‘package com.pk_1’.
>
> Note that in the project properties, you can reference other Java
> projects, which means that for example for the test projects, you
> don’t need to put pk_1.jar in the classpath, but you can refer to the
> classes directly. Nothing prevents you from including the jar, though.
>
> H.
Previous Topic:Obfuscation of eclipse plugins
Next Topic:Unable to set white foreground color (text editor)
Goto Forum:
  


Current Time: Wed May 07 07:09:39 EDT 2025

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

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

Back to the top