Cycle in build path [message #178601] |
Mon, 20 September 2004 23:26  |
Eclipse User |
|
|
|
Originally posted by: me.BarryBurd.com
Eclipse is complaining because I have a cycle in my build path. (See the
code below.) I understand that there's a cycle, but does this mean that
certain legal Java code is illegal in Eclipse? The code compiles and runs
with javac, but Eclipse finds the structure to be objectionable. Does this
mean that some valid code can't be imported into Eclipse?
Here's the (admittedly convoluted) code:
In project Drawings:......
package com.allmycode.drawings;
import java.awt.Graphics;
public class Drawing {
protected int x = 40, y = 40, width = 40, height = 40;
public void paint(Graphics g) {
g.drawOval(x, y, width, height);
}
}
package com.allmycode.drawings;
import com.allmycode.frames.ArtFrame;
class ShowFrameWideBB {
public static void main(String args[]) {
Drawing drawing = new Drawing();
drawing.width = 100;
drawing.height = 30;
ArtFrame artFrame = new ArtFrame(drawing);
artFrame.setSize(200, 100);
artFrame.setVisible(true);
}
}
In project Frames:......
package com.allmycode.frames;
import com.allmycode.drawings.*;
import javax.swing.JFrame;
import java.awt.Graphics;
public class ArtFrame extends JFrame {
Drawing drawing;
public ArtFrame(Drawing drawing) {
this.drawing = drawing;
setTitle("Abstract Art");
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void paint(Graphics g) {
drawing.paint(g);
}
}
|
|
|
Re: Cycle in build path [message #178644 is a reply to message #178601] |
Tue, 21 September 2004 05:27   |
Eclipse User |
|
|
|
Cycles in code are no problem. The problem are cyclic build paths - e.g.
ProjectA has ProjectB on its build path, and ProjectB has ProjectA on its
build path.
If you really need circular dependencies and don't care about possible
performance hits, you can switch the check off in Preferences > Java >
Compiler > Build Path: Set "Circular dependencies" to "Warning".
HTH
Markus
Barry Burd wrote:
> Eclipse is complaining because I have a cycle in my build path. (See the
> code below.) I understand that there's a cycle, but does this mean that
> certain legal Java code is illegal in Eclipse? The code compiles and runs
> with javac, but Eclipse finds the structure to be objectionable. Does this
> mean that some valid code can't be imported into Eclipse?
> Here's the (admittedly convoluted) code:
>
> In project Drawings:......
>
> package com.allmycode.drawings;
>
> import java.awt.Graphics;
>
> public class Drawing {
> protected int x = 40, y = 40, width = 40, height = 40;
>
> public void paint(Graphics g) {
> g.drawOval(x, y, width, height);
> }
> }
>
> package com.allmycode.drawings;
>
> import com.allmycode.frames.ArtFrame;
>
> class ShowFrameWideBB {
>
> public static void main(String args[]) {
> Drawing drawing = new Drawing();
> drawing.width = 100;
> drawing.height = 30;
>
> ArtFrame artFrame = new ArtFrame(drawing);
> artFrame.setSize(200, 100);
> artFrame.setVisible(true);
> }
> }
>
> In project Frames:......
>
> package com.allmycode.frames;
>
> import com.allmycode.drawings.*;
> import javax.swing.JFrame;
> import java.awt.Graphics;
>
> public class ArtFrame extends JFrame {
> Drawing drawing;
>
> public ArtFrame(Drawing drawing) {
> this.drawing = drawing;
> setTitle("Abstract Art");
> setDefaultCloseOperation(EXIT_ON_CLOSE);
> }
>
> public void paint(Graphics g) {
> drawing.paint(g);
> }
> }
>
>
|
|
|
|
Re: Cycle in build path [message #178714 is a reply to message #178692] |
Tue, 21 September 2004 11:07  |
Eclipse User |
|
|
|
Originally posted by: richkulp.NO.SPAM.us.ibm.com
Basically for java projects ignore the "Project References." This is for
controlling non-java builders. For java projects the projects required
to compile the project are controlled through the Java Build Path
instead from the Projects tab on the build path.
--
Thanks, Rich Kulp
|
|
|
Powered by
FUDForum. Page generated in 0.02508 seconds