Answer the question
In order to leave comments, you need to log in
How to import a package without knowing its full name?
Hello.
There is a package net.minecrft.server.v1.8_R3 which belongs to the server core, and I need from it, for example, the RemoteStatusListener class, but the problem is that in different versions of the kernel, a different package name, for example, in 1.8 there will already be a net.minecrft package. server.v1.8_R1, and, as it were, there are no changes in this class. Googling a little, I found something about dynamic loading, I didn’t really understand, maybe this is a solution, I hope you tell me here.
There are no more packages with a similar name, that is, net.minecrft.server.*, there is only a version at the end.
Thank you!
Answer the question
In order to leave comments, you need to log in
Here is a good description - tutorials.jenkov.com/java-reflection/dynamic-class...
Well, the necessary example of three lines under the heading Dynamic Class Loading
I will move it here
public class MainClass {
public static void main(String[] args){
ClassLoader classLoader = MainClass.class.getClassLoader();
try {
Class aClass = classLoader.loadClass("com.jenkov.MyClass");
System.out.println("aClass.getName() = " + aClass.getName());
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question