'Adjacent package does not exist
I have a public class Mountain
in Four\ Seasons\ Lab/things/Mountain.java
and try to import the class public class Triangle
, which is in Four\ Seasons\ Lab/shapes/Triangle.java
, using import shapes.Triangle
(note: import shapes.*
also doesn't work). For some reason, this keeps throwing package shapes does not exist
, as well as cannot find symbol
on any time I try to use the Triangle
class. How do I fix this?
Mountain.java
package things;
import shapes.Triangle;
import java.awt.Graphics;
import java.awt.Color;
public class Mountain {
private Triangle body;
public Mountain(int x, int y, int dx, int dy) {
this.body = new Triangle(
x, y + dy,
x + dx/2, y,
x + dx, y + dy
);
}
public void draw(Graphics g) {
body.draw(g);
}
}
Triangle.java
package shapes;
import java.awt.Graphics;
import java.awt.Color;
public class Triangle {
private Color color;
private int[] pointA;
private int[] pointB;
private int[] pointC;
public Triangle(Color color, int aX, int aY, int bX, int bY, int cX, int cY) {
this.color = color;
this.pointA = new int[] {aX, aY};
this.pointB = new int[] {bX, bY};
this.pointC = new int[] {cX, cY};
}
// more code
}
Note:
Runner
will runScenery
, which will runMountain
- The program must run in terminal through:
(in "Four Seasons Lab" directory)
$ javac *.java
$ java Runner
(it is shared via a .zip file containing only the .java files)
Solution 1:[1]
The problem wasn't with my IDE or my code or anything. I am using Atom as an IDE and linter-javac
package as a linter. This is just a problem with the linter.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | grepgrok |