Alright, consider the following example:
inside of the src/ folder, i have the following packages :
org/
com/
Class Foo is located in org.somepackage;
Class Doo is located in com.apackage;
Foo needs to access Doo using Class.forName();
if i try using Class.forName("com.apackage.Doo");
i get ClassNotFoundException as they are in different Packages.
how can Foo acess Doo in this hiearchy?
Here is some more background:
the complete asked about info :
this is my batch file, jar file, and the src file that has the file im trying to access.
this is the class in the src file :
this is my batch file :
now when i try to access the file Doo, this is the error:
Cheers.
This is the problem:
java -cp src -jar FooJar.jar
From the java
tool documentation:
When you use the -jar option, the specified JAR file is the source of all user classes, and other class path settings are ignored.
Try running it as:
java - cp src;FooJar.jar foo.Whatever
(where foo.Whatever
is the fully-qualified name of the class containing your main
method).
See more on this question at Stackoverflow