how to get a class with forName() in a different package?

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?


EDIT

Here is some more background:

the complete asked about info : enter image description here

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 :

enter image description here

this is my batch file : enter image description here

now when i try to access the file Doo, this is the error:

enter image description here

Cheers.

Jon Skeet
people
quotationmark

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).

people

See more on this question at Stackoverflow