so i can't find a question already asked that answers my exact problem. I have a package that i wrote in eclipse that i exported as a jar library to use in the processing ide. in processing i have a sketch that has a class that calls a class that is in the package. when i try to compile i get this error:
Pirate(processing.core.PApplet,java.lang.String,processing.core.PVector,float,float,int,int) is not public in fsg.pvzclone.pirateunits.Pirate; cannot be accessed from outside package
[javac] fsg.pvzclone.pirateunits.Pirate pirate1 = new fsg.pvzclone.pirateunits.Pirate(this, "Pirate", pinPoint, pWidth, pHeight, 1, 1).displayPirate();
does anyone know why i can't access the class? I have both the class and constructor set as public
, so i'm not sure why the class can't be accessed. any help would be greatly appreciated.
CONSTRUCTOR CODE:
package fsg.pvzclone.pirateunits;
import processing.core.*;
public class Pirate {
public String pirateClass;
int classId;
PVector pinPoint;
float width;
float height;
int id;
PApplet parent;
public Pirate(processing.core.PApplet _parent, String _pirateClass, PVector _pinPoint,
float _width, float _height, int _classId, int _id) {
parent = _parent;
pirateClass = _pirateClass;
classId = _classId;
width = _width;
height = _height;
pinPoint = _pinPoint;
id = _id;
}
public void displayPirate() {
parent.fill(13, 183, 20, 255);
parent.stroke(7, 59, 9, 255);
parent.rect(this.pinPoint.x-this.width/2, (float)(this.pinPoint.y-this.height*.75), this.width, this.height);
}
}
CODE CALLING PIRATE CLASS:
fsg.pvzclone.pirateunits.Pirate pirate1 = new fsg.pvzclone.pirateunits.Pirate(this, "Pirate", pinPoint, pWidth, pHeight, 1, 1).displayPirate();
try to create public default constructor in Pirate class and try to call it as:
public class Pirate{
public Pirate () {}
....
}
calling code:
fsg.pvzclone.pirateunits.Pirate emptyPirate1 = new fsg.pvzclone.pirateunits.Pirate();
And check you still get the same error msg?
Not sure this is your problem, but it is a problem and too long for a comment - you should replace;
fsg.pvzclone.pirateunits.Pirate pirate1 = new fsg.pvzclone.pirateunits.Pirate(this, "Pirate", pinPoint, pWidth, pHeight, 1, 1).displayPirate();
with:
fsg.pvzclone.pirateunits.Pirate pirate1 = new fsg.pvzclone.pirateunits.Pirate(this, "Pirate", pinPoint, pWidth, pHeight, 1, 1);
pirate1.displayPirate();
Since displayPirate
returns nothing, not a pirate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With