If i have a class inside a package say mypackage.myclass and want to access a package's class that is in the same folder as the package's root (not inside the package) say anothepackage.anotherclass how can I actually do so?
Example presented in code:
// directories are preceded by a DIR, files are preceded by a CLASS
// any level deeper is preceded by a [Tab]
DIR mypackage
CLASS myclass
DIR myinnerpackage
CLASS myinnerclass
DIR anotherpackage
CLASS anotheclass
CLASS yetanotherclass
DIR org
DIR apache
DIR commons
DIR exec
CLASS DefaultExecutor
Inside the file myclass:
package mypackage;
public class myclass{
// simplest example code I can come up with
org.apache.commons.exec.DefaultExecutor exec = new org.apache.commons.exec.DefaultExecutor();
}
Why does this piece of code not work for me?
Generally how can myclass access anotherclass or yetanotherclass and how can myinnerclass access them as well? Try to refrain for imports as I want to use certain members of each class only (some variables have same names and will get things messed)! Thanks in advance!
Use relative path:
String dir = "../anotherpackage/anotheclass";
^
|
-- (go one level up)
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