File jarFile = null;
URL url = null;
try {
String path = "C:\\Users\\Orange\\Documents\\Lab5\\RpcServer\\MaxMin.jar";
jarFile = new File(path);
url = new URL("file", null, -1, jarFile.getAbsolutePath());
URLClassLoader classLoader = new URLClassLoader(new URL[] {url});
return classLoader.loadClass("nhu.lab5.maxmin.MaxMinImpl").newInstance();
That doesn't work. But if I replace the path to where the original file is at, it works fine.
File jarFile = null;
URL url = null;
try {
String path = "C:\\Users\\Orange\\Documents\\Lab5\\MaxMin\\dist\\MaxMin.jar";
jarFile = new File(path);
url = new URL("file", null, -1, jarFile.getAbsolutePath());
URLClassLoader classLoader = new URLClassLoader(new URL[] {url});
return classLoader.loadClass("nhu.lab5.maxmin.MaxMinImpl").newInstance();
I'm sure I copy the exact same file, but I don't understand why the first code would work but the second one doesn't. Help?
Thank you in advance.


Sign In
Create Account


Back to top









