So this is the first time I've tried running my Jar file on another computer. Both computers are Windows 10. I'm getting what I've determined from research are "classpath" issues which makes sense when running it on the foreign computer: As seen here What i'm unsure of is a solution to solve this problem. Is there a solution I can undertake to fix it within the Jar, so that all the user has to do is run this jar program in the CMD without extra commands? (Only commands user ought to be inputting are java -jar) Specifics would be very helpful if there are solutions.
If there are none, what commands does the user need to input? And I know already that Class not Found errors are sub-errors of NoClassDefFound, I'm aware of the problem, how it works, and the diagnosis but I'm trying to find a solution.
EDIT I think the problem is my libraries are in the folder, while the .jar file with the source code is separate (all within my dist folder). So how do I run the files altogether to be functional on foreign computers?
EDIT 2 Solved the problem. Logically I was running a jar file w/o a library folder to reference the imports. When I zipped up the dist and ran it from the foreign computer, it worked totally fine.
Most likely it is related to class loading undeterministic order, and conflict between the same package defined by more than one jar file in your app dependencies
In order to identifying actual source of loaded class you can run the following snippet
package com.asd;
import java.net.URL;
public class Main {
public static void main(String[] args) {
Class aClass = YouClas.class;
String classResource = Timestamp.class.getName().replace(".", "/")+".class";
System.out.println(classResource);
URL url =aClass.getClassLoader().getResource(classResource);
System.out.println(url);
}
}