Reputation: 2055
I would like to use a class from some project in another Java Web project. Unfortunately I don`t know what I have do to call this class. I understand I have to write package etc. but how?
This class is visible in Java website project
public class MojaWygenerowanaKlasaa {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Test2 test2 = new Test2();
String Zmienna = test2.query2();
}
// public string Query2() {
// return jpsquerie1.dana;
//}
}
This class is visible in another project SBQL4J_EXAMPLE1 -> file(src) -> package -> example
package example;
public class Test2 {
public String query1(){
return "aa";
}
}
I added the project here.
Upvotes: 1
Views: 3939
Reputation: 16406
As I see you have already added the project that contains classes you need to another project's build path ("Required projects on the build path" on the picture above).
Now in the file that needs that class just import that class.
Example:
import pl.example.SomeClass;
public class Test {
...
public static void main(String[] args) {
SomeClass someClass = new SomeClass();
...
}
...
}
In other words, you can freely acces all classes that are on the project's build path in a standard way.
Upvotes: 2