Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Eclipse how to: compile a single file or only few files
Eclipse how to: compile a single file or only few files [message #163629] Thu, 03 August 2006 04:41 Go to next message
Eclipse UserFriend
Originally posted by: mansour.own.net

Hi EveryBody:
I am very new to eclipse. I found it popular and alot of companies are
encouraging and requesting hteir deevelopers to be comfortable with this
IDE. I decided to give it a shot. It's very rich that it takes alot of
time (at least for me) to find out how perform a simple task. The
problem I came accross now is how to compile only few files. For
example, assuming I'm developing a project for a client/server
transaction, or a small chat program, and I need to get the files needed
only to test the client, how do I get around compiling htese files. If
we take the chat room example, I have a client, server, and a package
that contains the java classes need by both.

- client
-file1
-file2
-server
-file1
-file2
-file3
-common
-file1
-file 15

Now I need to compile the classes for client then package them into a
jar file. Do the same for the server. Any one knows if this is possible
with eclipse, or any idea ??
Thanx in advance.
Re: Eclipse how to: compile a single file or only few files [message #163700 is a reply to message #163629] Thu, 03 August 2006 12:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: steve.raasch.merastar.com

I too am relativly new to the Eclipse platform, and I do not think the
Eclipse itself will solve your problem. The method that I use to compile,
and to jar the classes is to make an ANT Build file that you can then
control exactly what you want done.(You could see 'Ant - The definitive
guide' from O'Reilly press)
Re: Eclipse how to: compile a single file or only few files [message #163708 is a reply to message #163629] Thu, 03 August 2006 13:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jefmyers.us.ibm.com

Mansour,

If you have Build Automaticly enabled in your workspace, the Java source
is built every time you save the file with modifications. The resulting
class files are hidden in the Package Explorer, but you can see them in
the Navigator view. So basically, everything should be automatically
built, and you can export your JAR whenever you want. Alternatively,
you can set up an Ant task to build your project and create your JAR,
and run that using the External Tools function. Details for using Ant
within Eclipse are available in the help docs.

Hope this helps,
- Jeff
Re: Eclipse how to: compile a single file or only few files [message #163729 is a reply to message #163708] Thu, 03 August 2006 16:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mansour.own.net

Jeff Myers wrote:
> Mansour,
>
> If you have Build Automaticly enabled in your workspace, the Java source
> is built every time you save the file with modifications. The resulting
> class files are hidden in the Package Explorer, but you can see them in
> the Navigator view. So basically, everything should be automatically
> built, and you can export your JAR whenever you want. Alternatively,
> you can set up an Ant task to build your project and create your JAR,
> and run that using the External Tools function. Details for using Ant
> within Eclipse are available in the help docs.
>
> Hope this helps,
> - Jeff

Jeff, Steve, Thank you for taking the time to reply.
However, I am new to eclipse and the last thing I am looking to do is to
learn ant. I am looking to do everything I need in eclipse. I know about
the compiling options and the automatic compilation. However what I need
is to compile the classes needed for that part. For example

-client:
-file1
-file2
-server:
-file1
-commonFiles:
-file1 ...... -file15
-targetFoleder:

How can I get the client files with th efiles needed from the common, to
compile into "targetFolder", so that I can create a JAR archieve and do
the same for th eserver. As I mentioned earlier, is't there a way to do
this with out ANT, it just adds one more thing to learn now.

Thank you.
Re: Eclipse how to: compile a single file or only few files [message #163746 is a reply to message #163729] Thu, 03 August 2006 19:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jefmyers.us.ibm.com

Mansour,
Are the client, server and commonFiles split out into separate projects?
You'll probably have an easier time if you make each of them as source
folders within the same project, or different packages within the same
source folder. Then all of the compiled objects will be put in the same
output folder. So for instance, you'd create a new Java project with
client "Create separate source and output folders" selected, then on the
second page, remove the default src folder in the list, and hit the
"Create a new Source Folder for the project" button at the top right,
and add client, server and commonFiles. Then at the bottom, change the
output folder to targetFolder. Then import your source into the
respective folders and everything should compile happily.

Hope this helps,
- Jeff
Re: Eclipse how to: compile a single file or only few files [message #163971 is a reply to message #163746] Fri, 04 August 2006 22:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mansour.own.net

Jeff Myers wrote:
> Mansour,
> Are the client, server and commonFiles split out into separate projects?
> You'll probably have an easier time if you make each of them as source
> folders within the same project, or different packages within the same
> source folder. Then all of the compiled objects will be put in the same
> output folder. So for instance, you'd create a new Java project with
> client "Create separate source and output folders" selected, then on the
> second page, remove the default src folder in the list, and hit the
> "Create a new Source Folder for the project" button at the top right,
> and add client, server and commonFiles. Then at the bottom, change the
> output folder to targetFolder. Then import your source into the
> respective folders and everything should compile happily.
>
> Hope this helps,
> - Jeff
Jeff:
Thanx alot, It sound a great idea and close to what I want. I'll try
this soon, and let you know. The way I was going to solve this is by
including and excluding the files from the path, then compile them into
a common folder, then create a jar file from that folder, clean and so
the same for the rest of the sections. This seemed to be great, however,
I'll try to do them in separate folders. I dont know if this will
compile and include "only" the classes I need from the common folder, as
the common folder really is a package "NOT A JAR", and it contains alot
of files that I dont want to include, I think this wil be the only
problem. If you have any suggestion then let me know. thank you.
Re: Eclipse how to: compile a single file or only few files [message #163979 is a reply to message #163971] Sat, 05 August 2006 00:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mansour.own.net

Still can not get what I want. I dont know why things are that
complicated. OK, again my problem, I am working on a project of many
parts, (Server1, Server2, client1, client2,....,commonFiles). Now the
commonFiles are in a package called common.util. There are many classes
for each part. I need to test the project and use it, the best way is to
put every part in a Jar file, for easier access. Now When I compile the
package all the files go into on single directory, and the process of
sorting them out to create a jar file for each part becomes boring and
time consuming, therefore, I decided to choose the files included in
each part and use include/exclude from the path then compile into a
specific folder and create a jar file. Again this process is length when
you have 40+ classes. A member on this list suggested wrapping them in a
"source folder". I did, but... getting errors in the source code not
being able to see the rest of the classese (package common.util).
Any Help ????



> Jeff Myers wrote:
>
>> Mansour,
>> Are the client, server and commonFiles split out into separate
>> projects? You'll probably have an easier time if you make each of them
>> as source folders within the same project, or different packages
>> within the same source folder. Then all of the compiled objects will
>> be put in the same output folder. So for instance, you'd create a
>> new Java project with client "Create separate source and output
>> folders" selected, then on the second page, remove the default src
>> folder in the list, and hit the "Create a new Source Folder for the
>> project" button at the top right, and add client, server and
>> commonFiles. Then at the bottom, change the output folder to
>> targetFolder. Then import your source into the respective folders and
>> everything should compile happily.
>>
>> Hope this helps,
>> - Jeff
>
> Jeff:
> Thanx alot, It sound a great idea and close to what I want. I'll try
> this soon, and let you know. The way I was going to solve this is by
> including and excluding the files from the path, then compile them into
> a common folder, then create a jar file from that folder, clean and so
> the same for the rest of the sections. This seemed to be great, however,
> I'll try to do them in separate folders. I dont know if this will
> compile and include "only" the classes I need from the common folder, as
> the common folder really is a package "NOT A JAR", and it contains alot
> of files that I dont want to include, I think this wil be the only
> problem. If you have any suggestion then let me know. thank you.
>
Re: Eclipse how to: compile a single file or only few files [message #164276 is a reply to message #163979] Mon, 07 August 2006 13:11 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.rizzoweb.com

Mansour wrote:
> Still can not get what I want. I dont know why things are that
> complicated. OK, again my problem, I am working on a project of many
> parts, (Server1, Server2, client1, client2,....,commonFiles). Now the
> commonFiles are in a package called common.util. There are many classes
> for each part. I need to test the project and use it, the best way is to
> put every part in a Jar file, for easier access. Now When I compile the
> package all the files go into on single directory, and the process of
> sorting them out to create a jar file for each part becomes boring and
> time consuming, therefore, I decided to choose the files included in
> each part and use include/exclude from the path then compile into a
> specific folder and create a jar file. Again this process is length when
> you have 40+ classes. A member on this list suggested wrapping them in a
> "source folder". I did, but... getting errors in the source code not
> being able to see the rest of the classese (package common.util).
> Any Help ????

As already suggested, there are 2 recommendations:
A) Separate into multiple projects, so that each "part" is its own
project (remember that projects can depend on other projects, such as
the common util one).

B) Keep one project but write an Ant script to build your JARs (based on
package name, I assume). Such an Ant script is trivial to write, and if
you're doing Java development you really should know Ant anyway.

In either case, it is strongly recommended that you open the Eclipse
Help and go through the Getting Started sections under Java Development
User Guide. There are tutorials for project organization and integrating
Ant into the Eclipse build cycle - those will help you a lot.

Hope this helps,
Eric
Re: Eclipse how to: compile a single file or only few files [message #164415 is a reply to message #164276] Tue, 08 August 2006 00:49 Go to previous message
Eclipse UserFriend
Originally posted by: mansour.own.net

Eric Rizzo wrote:
> Mansour wrote:
>
>> Still can not get what I want. I dont know why things are that
>> complicated. OK, again my problem, I am working on a project of many
>> parts, (Server1, Server2, client1, client2,....,commonFiles). Now the
>> commonFiles are in a package called common.util. There are many
>> classes for each part. I need to test the project and use it, the best
>> way is to put every part in a Jar file, for easier access. Now When I
>> compile the package all the files go into on single directory, and the
>> process of sorting them out to create a jar file for each part becomes
>> boring and time consuming, therefore, I decided to choose the files
>> included in each part and use include/exclude from the path then
>> compile into a specific folder and create a jar file. Again this
>> process is length when you have 40+ classes. A member on this list
>> suggested wrapping them in a "source folder". I did, but... getting
>> errors in the source code not being able to see the rest of the
>> classese (package common.util).
>> Any Help ????
>
>
> As already suggested, there are 2 recommendations:
> A) Separate into multiple projects, so that each "part" is its own
> project (remember that projects can depend on other projects, such as
> the common util one).
>
> B) Keep one project but write an Ant script to build your JARs (based on
> package name, I assume). Such an Ant script is trivial to write, and if
> you're doing Java development you really should know Ant anyway.
>
> In either case, it is strongly recommended that you open the Eclipse
> Help and go through the Getting Started sections under Java Development
> User Guide. There are tutorials for project organization and integrating
> Ant into the Eclipse build cycle - those will help you a lot.
>
> Hope this helps,
> Eric

First of all: Thank you every body, I really appreciate the help that
everyone was giving.
Now, I'm able to achieve what I needed, and "from my prespective" I am
not surprised that eclipse is growing fast. I am getting more
comfortable using it.
Ok, I decided to write a small instruction or steps showing how I got
what I needed, in case someone needed to know or faced the same problem.

As I was adviced, I broke my project into source folders, and stored in
each folder the classes I need. Then I created a target folder for all
these sections. For example:

-client1.src:
-file1.java file2.java file3.java

-client1.out
-file1.class file2.class file3.class .... file50.java

-commonFiles:
-file1.java file2.java file3.java ......... file100.java

and of course I did the same for all other sections (server, client2
....etc).
Now I can easily just create a Jar file from each section and include
the target for commonFiles. I would like to be able to include only the
classes needed from common, but that's not a big issue for me at this
point. I know I will be able to do this with Ant. I am really glade that
I can get things done easily this way, and without the need to learn a
new piece of Technology like Ant. I am not against it, I know it's
useful, but one step at a time. I will wait until I get very comfortable
with Eclipse and with the basic features it offers, by then, I would
know what functionality is missing and try to do it with Ant.

Thank you again every body.
Previous Topic:Problem downloading Callisto package
Next Topic:Java on a mac: can't see the bin folder
Goto Forum:
  


Current Time: Mon Sep 23 08:19:46 GMT 2024

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

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

Back to the top