how to clean up unused java file in eclipse

M

mcheung63

Dear All
I have a project in eclipse, it has many java files, they are taken from an open source project. I will call one single function from one class, how can i clear out all unused classes?
thanks
from Peter ([email protected])
 
J

Joerg Meier

Dear All
I have a project in eclipse, it has many java files, they are taken from an open source project. I will call one single function from one class, how can i clear out all unused classes?
thanks

Select the files you don't want and press the Delete key. There is no
automatic way to do what you want. An optimizer/shrinker such as ProGuard
can be used to clean away unused classes from your compiled output, but its
use is not trivial.

Also, just because you only call one function doesn't mean no other classes
are needed - the function or the class holding the function itself might
reference a multitude of classes, possibly even all of them.

Liebe Gruesse,
Joerg
 
L

Lew

mche...
I have a project in eclipse, it has many java [sic] files, they are taken
from an open source project. I will call one single function from one class,
how can i [sic] clear out all unused classes?

By not copying them into your project.

However, this is both not the right way to do it nearly always, and risks
your violation of license terms. Check with a lawyer to ensure that you comply
with the open-source license.

Your question is rather odd. What one function from what one class is so
valuable that you'd lift it, and what open-source project has such a gem
yet none of its other functionality will serve?

Why not just add the JAR to your libraries? What's the big deal?
 
A

Arne Vajhøj

Dear All I have a project in eclipse, it has many java files, they
are taken from an open source project. I will call one single
function from one class, how can i clear out all unused classes?

That will become a maintenance burden.

I would just have the calling project have the jar
file with the binary of the entire open source thing in
classpath.

That makes upgrade easy (assuming the function you use
has not changed).

And the jar file will typical just be a few hundred
KB. If that is a problem due to unusual constraints
then look for one of the obfuscator tools that
removes unused binary code.

Putting part of the source code of the open source
project in your project tree will make it cumbersome
to upgrade.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top