Class.forName("AClassName") always yields in an exception

Dear Experts
I am trying to get a classname at runtime and Class c = Class.forName always returns an exception
I will appreciate your help in this regard. Anyways the full code is as follows:
interface MyInter
    void accept();
    void display();
class IntegerSorter implements MyInter {
    public void accept()
        System.out.println("IntegerSorter....................");
    public void display()
        System.out.println("Displays IntegerSorter...........");
class StringSorter implements MyInter {
    public void accept()
        System.out.println("StringSorter....................");
    public void display()
        System.out.println("Displays StringSorter.............");
public class Main {
    public static void main(String[] args) {
        Class c=null;
        MyInter m=null;
        String s="IntegerSorter";
        try
             c = Class.forName(s);
        } catch (Exception e1) {
            System.err.println(e1.getMessage());
        try {
            m = (MyInter) c.newInstance();
        } catch (Exception e) {
            System.err.println(e.getMessage());
        m.accept();
        m.display();
}Edited by: standman on Mar 18, 2011 1:41 PM

standman wrote:
I am trying to get a classname at runtime and Class c = Class.forName always returns an exceptionThat's not enough information; which Exception?
Plus, I ran your exact code o my machine, and got absolutely no exception. Are you posting the exact code that demonstrates the problem?
try
c = Class.forName(s);
} catch (Exception e1) {
System.err.println(e1.getMessage());
}As an aside, don't log exceptions like that. Although it looks fine on so small a code, it's way not enough information if you have to debug such a "trace" in a non-trivial program.
Instead log the exception's stack trace ( e1.printStackTrace() ), or use a logging library (for bigger programs).
Regards,
J.

Similar Messages

  • Error class not found with Class.forName("oracle.jdbc.driver.OracleDriver")

    sorry Got the solution...!!!!
    Hi
    I am trying to connect to oracle database on the server, oracle client installed on working m/c, I have placed classes111.zip (from oracle 8) in jdk1.1.8demojrelibext folder and I have set the classpath to the ext folder. The code
    try
    Class.forName("oracle.jdbc.driver.OracleDriver");
    catch(Exception e)
    when I run this code , error as
    [[ java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver ]]
    Please reply what are settings I should to to load this oracle driver,
    Thanks
    Mayank
    Message was edited by:
    user560333

    I currently have this same problem. How did you solve yours see my post Cant find suitable driver.

  • Class.forName related

    this is my code :
    public class ClassTest {
    public ClassTest() {
    try{
    System.out.println( "***** : " + System.getProperty( "java.class.path") );
    System.setProperty( "java.class.path", System.getProperty( "java.class.path") + ";C:\\injar.jar" );
    System.out.println( "NEW PATH : " + System.getProperty( "java.class.path") );
    Class c = Class.forName( "com.cu.injar.Searcher" );
    }catch( Exception e ){
    e.printStackTrace();
    public static void main(String[] args) {
    ClassTest classTest1 = new ClassTest();
    but i still got ClassNotFoundException, i just want to load class at runtime from jar,
    note : i want to add selected jar into JVM's classpath at runtime then load

    I posted a similar problem a while back, and got two good replies. See http://forum.java.sun.com/thread.jsp?forum=4&thread=276737
    Answer provided by Friends of the Water Cooler. Please inform forum admin via the
    'Discuss the JDC Web Site' forum that off-topic threads should be supported.

  • Applet - Class.forName..

    I have an applet which is loading fine but my combo boxes aren't getting populated - I'm getting "Failed to load JBDC/ODBC driver" because of the following:
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    catch(Exception e){
    System.out.println("Failed to load JBDC/ODBC driver");
    Any ideas?
    Jacintha

    What are you actually trying to do? Are you connecting through a Servlet/JSP or is it a standalone applet? Seems like you are using Windows. Use ODBC Datasources in the Control Panel to set a DSN. Which database are you using? Which Platform are you working on and what is the objective of your applet?
    I have an application and when you click a particular button on a jsp - you are directed to the html file that loads the applet. I'm using an Oracle database. When the applet loads ( a swing applet) the buttons etc comes up but the combo boxes are not populated - should be populated from the database - I have been looking through this forum and some have mentioned to sign the applet - I am in the process of doing this - I don't know if you know anything about this. I have got as far as signing the jar file and exporting the public key certificate - but now it goes into details about the code receiver which I'm getting puzzled about. I am using the following site: http://java.sun.com/docs/books/tutorial/security1.2/toolsign/index.html. I don't know what direction to go now!

  • Class.forName() throws null exception in servlet

    Hi, just wondering if anyone having this similar problem:
    when i try to load a class using Class.forName() method inside a servlet, it throws null exception.
    1) The exception thrown is neither ClassNotFoundException nor any other Error, it's "null" exception.
    2) There's nothing wrong with the code, in fact, the same code has been testing in swing before, works perfectly.
    3) I have include all necessary jars/classes into the path, even if i haven't, it should throw ClassNotFoundException instead, not "null" exception.

    I have tried to detect any possible nullable variable, and it is able to run until line 15. The exception thrown is actually null only... not NullPointerException... which is why i have confused...
    the message i received is "PlugInException: null".
    The code is at follow:
    * Load plugin
    * @return ArrayList of plugins
    * @exception PlugInException PlugInException
    01 public ArrayList loadPlugin()
    02 throws PlugInException
    03 {
    04 PlugIn plugin;
    05 ArrayList plugins = new ArrayList();
    06
    07 for (int i = 0; i < configLoader.getPluginTotal(); i++)
    08 {
    09 try
    10 {
    11 if (debugger > 0)
    12 {
    13 System.out.print("Loading " configLoader.getPluginClass(i) "...");
    14 }
    15 if (Class.forName(configLoader.getPluginClass(i)) == null)
    16 {
    17 if (debugger > 0)
    18 {
    19 System.out.print(" not found");
    20 }
    21 }
    22 else
    23 {
    24 if (debugger > 0)
    25 {
    26 System.out.println(" done");
    27 }
    28 plugin = (PlugIn)(Class.forName(configLoader.getPluginClass(i)).newInstance());
    29 plugin.setContainer(container);
    30 plugins.add(plugin);
    31 }
    32 }
    33 catch (Exception e)
    34 {
    35 throw new PlugInException("PlugIn Exception: " + e.toString());
    36 }
    37 }
    38
    39 return plugins;
    40 }

  • Class.forName() debunked

    This issue is about: Dynamic loading and Inheritance.
    Debugging an odd ClassNotFoundException in a J2EE Application, I was involved investigating deeply Class.ForName(). This method - namely the version with only the class name as parameter - is used inside xsdbeans.jar, an optiopnal library, shipped with IBM WebSphere 5.x. Moving the jar from the EAR classloader to the server runtime classloader caused weird behavior on my app.
    I try to simplify the core question:
    Suppose class E extends B. Base class B declares an instance method, dynLoad(String name) that uses internally Class.forName(String name).
    Say 'e' an instance of E. Invoking e.dynLoad("Foo"), Class.forName("Foo") should use the ClassLoader of current class. But which is the 'current class': E or B? Is it the class of current object (E) or the declaring superclass (B)?
    My instinctive answer was: E. But my J2EE app was behaving as the current class was B. Indeed E and B may be defined by different classloaders, and this makes a big difference.
    A rapid lookup at Sun's docs confirmed my first hypothesis:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#forName(java.lang.String)
    > Returns the Class object associated with the class or interface with the given string name.
    Invoking this method is equivalent to:
    Class.forName(className, true, currentLoader)
    where currentLoader denotes the defining class loader of the current class.
    ok, this is a little misleading, but going on:
    http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html#forName(java.lang.String,%20boolean,%20java.lang.ClassLoader)
    > For example, in an instance method the expression:
    >
    Class.forName("Foo")
    is equivalent to:
    Class.forName("Foo", true, this.getClass().getClassLoader())
    Not equivocal. The current class is the class of current object, no matter (apparently) if the instance method is declared in a superclass.
    Right? Wrong. Here a minimal counter-example:
    //-- B.java
    import java.net.*;
    public class B {
        public void dynLoad(String name) throws Exception {
            System.out.println(getClass().getSuperclass()
                + " defining classloader is: "
                + getClass().getSuperclass().getClassLoader());
            System.out.println(getClass()
                + " defining classloader is: "
                + getClass().getClassLoader());
            System.out.println("\n1) Class.forName(\""+name+"\");");
            // Loading with 'currentLoader'
            Class.forName(name)
                .newInstance();
            System.out.println("\n2) Class.forName(\""+name
                +"\", true, this.getClass().getClassLoader());");
            // This should be equivalent (by Sun J2SE API spec)
            Class.forName(name, true, this.getClass().getClassLoader())
                .newInstance();
        public static void main(String[] args) {
            ClassLoader syscl = ClassLoader.getSystemClassLoader();
            if (!URLClassLoader.class.isInstance(syscl)) {
                System.err.println("Cannot continue the trick.");
                System.exit(1);
            URL[] urls = ((URLClassLoader)syscl).getURLs();
            // Yet Another ClassLoader
            URLClassLoader yacl = new URLClassLoader(urls) {
                // Force Parent-last delegation policy to assure
                // demanded classes are defined by _this_ classloader
                public Class loadClass(String name)
                    throws ClassNotFoundException {
                    Class c = findLoadedClass(name);
                    if (c == null) {
                        try {
                            // Simulate no visibility to base class to assure
                            // it is _not_ defined by this classloader too
                            if (name.equalsIgnoreCase("B")) {
                                throw new ClassNotFoundException();
                            c = findClass(name);
                        } catch (ClassNotFoundException e) {
                            c = getParent().loadClass(name);
                    return c;
            try {
                // Loading class E with a different classloader
                Class c = yacl.loadClass("E");
                c.getMethod("dynLoad", new Class[]{String.class})
                    .invoke(c.newInstance(), new Object[]{"Foo"});
            } catch (Exception ex) {
                ex.printStackTrace();
                System.exit(1);
    //-- E.java
    public class E extends B {
    //-- Foo.java
    public class Foo {
      public Foo() {
        System.out.println(getClass()
          + " defining classloader is: "
          + getClass().getClassLoader());
    }Running above B.main() produce the following output on Sun JDK 1.3, 1.4.2, 1.5:
    > class B defining classloader is: sun.misc.Launcher$AppClassLoader@3d200480
    class E defining classloader is: B$1@3d2c0480
    1) Class.forName("Foo");
    class Foo defining classloader is: sun.misc.Launcher$AppClassLoader@3d200480
    2) Class.forName("Foo", true, this.getClass().getClassLoader());
    class Foo defining classloader is: B$1@3d2c0480
    The evidence is that classloader used is not the same. in the case 1) it uses the classloader of superclass B. Hence the two form of Class.forName() invocation are not equivalent, as stated in Sun documentation.
    Disclosure
    The evidence is confirmed and explained looking at Sun's implementation of java.lang.Class.java and java.lang.ClassLoader.java: finally the Class.forName(String name) relies on sun.reflect.Reflection.getCallerClass(int) to find the famous 'current class' mentioned in the javadocs. This undocumented method returns the i-th caller class of current stack frames; each stack frame represents a method invocation coupled with its declaring class.
    I wonder why in Sun docs this poorly explained issue was remaining immutable from 1.3 to date. Furthermore: which was the intended behavior? Another reason to the long said "Class.forName() is evil..." or am I missing something?
    regards, Lorenzo

    Of course, it comes down to the question: What is the current class?
    Not something well defined. You are looking for this.getClass(), it's taking the class at compile time. If it went your way, woundn't that create an inconsistency in forName in static vs instance contexts?
    Actually I think the static approach is more natural, because it means that forName behaves the way that resolving external references work. Your way would also go against the spirit of Java security policies which requires references down the classloader chain something to be treated with suspision.
    The mechanism intended, I think, for these situations is the contextClassLoader property of Thread. When executing plugin type code the contextClassLoader should be set to the ClassLoader that loaded the plugin, and any references to resources or dynamic class loads from the plugin should be made using the contextClassLoader. This enables your shared library code to access classes and resources on behalf of the plugin code with access to classes and resources inside the plugin.
    Thus, if you write library code or other container stuff likely to be called from a plugin you should probably always use:
    Class cls = Thread.currentThread().getContextClassLoader().loadClass("foo");

  • Class.forName, how to use it in the case?

    we have a java application:
    c:\app\TestForName.class
    inside the app, there is a call:
    Class.forName("ClassLib");
    ClassLib.class is a simplest class for testing with no package.
    ClassLib.class can be in any directory except the app's directory
    c:\app
    because ClassLib.class stands for our library class for multiple projects and multiple uses, it is not allowed to be in a special app directory.
    and, ClassLoader and URLClassLoder are not suitable in our case.
    i tried following 3 ideas, none of them is OK, please help.
    1. put ClassLib.class in directory
    c:\lib\
    (that is c:\lib\ClassLib.class)
    call application with command -cp
    java -cp c:\lib;....; TestForName
    (method Class.forName("ClassLib") call is inside TestForName.class)
    2. put ClassLib.class in
    c:\jdk\bin\
    (VM says it is one of "java.library.path")
    java -cp ....; TestForName
    3. put ClassLib.class in
    c:\jdk\JAR\classes\
    (VM says if is one of "sun.boot.class.path")
    java -cp ....; TestForName
    i really wondering how to make Class.forName() call successfuf inside application TestForName.class
    1. which directory is right place for ClassLib.class
    2. how to change command line or java code inside TestForName.class
    thx for any help.

    Why don't u use a class loader. Try this code
    // loader class
    public class Loader  extends ClassLoader {
        String path;
        public Loader(String path) {
              this.path = path;
        public Class findClass(String name) {
            byte[] b = loadClassData(path+name+".class");
            return defineClass(name, b, 0, b.length);
        private byte[] loadClassData(String name) {
            File file = new File(name);
            byte[] data = null;
            try {
                InputStream in = new FileInputStream(file);
                data = new byte[ (int) file.length()];
                for (int i = 0; i < data.length; i++) {
                    data[i] = (byte) in.read();
            catch (IOException ex) {
            file = null;
            return data;
    // in your caller class use
       Loader loader = new Loader(libPath); // lib path may be taken from a command line arg
       Object main = loader.loadClass("ClassLib", true).newInstance();I think this is what u r looking for
    Uditha Nagahawatta

  • Class.forName() with dynamic String

    I'm trying to create objects of a class whose name depends on a runtime database lookup. So my code looks like this:
    package com.mycompany.ourproduct.ourpackage;
    String className = rs.getString(1);
    Class c = Class.forName(className);
    When I run the program, I get a ClassNotFoundException. But everything runs fine if I replace the code above with this:
    package com.mycompany.ourproduct.ourpackage;
    // String className = rs.getString(1);
    String className = "com.mycompany.ourproduct.ourpackage.oursubpackage.MyClass"
    Class c = Class.forName(className);
    The problem seems to be in the dynamic linking. Although the class I'm trying to load is in a different package, it is a public class (and I can load it with a static string). Neither does moving it to the same package fix the problem.
    I've noticed that if I supply a mis-named class with a static string, the exception reads:
    java.lang.ClassNotFoundException: com.mycompany.ourproduct.misspelledpackage.SomeClass
    but the same exception prints as follows when the string comes from the database:
    java.lang.ClassNotFoundException: com/mycompany/ourproduct/misspelledpackage/SomeClass
    I thought the difference was one of compile-time linking and run-time linking, but oddly enough, I still get the dots for misspelled classes that I (1) supply on the command line, (2) read from a file, or (3) concatenate from command line arguments plus info from a file. It's just when I pull the class name from the database that I get the slashes. Does anyone know what's going on?
    Here's what I get from java -version:
    java version "1.2.2"
    Solaris VM (build Solaris_JDK_1.2.2_05a, native threads, sunwjit)
    Any help would be greatly appreicated!

    Hmm. Weird. Have you looked at the String you're getting back from the database? Does it have slashes or dots? (Should be dots.) Have you made sure any leading/trailing spaces have been trimmed? Try doing classname.equals("com.mycompany... etc.") to see if it really is the same string as the constant that does work.
    If it turns out the String is correct, and the only difference is whether that String came from a databaes or a literal, then I don't know what's going on. The first step, though, is to verify whether that's really the case, or if you're not getting the String you think you are.

  • Class.forName problem

    Hi,
    I'm using "Java Invocation API" to load a class and call a generic method of it,
    but the "forName" call fails with error:
         Exception in thread "Thread-4" java.lang.ClassNotFoundException: HelloWorld
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:217)
    here is my (pseudo) code:
    // connect to my class "HelloWorld"
    myClass = (*envP)->FindClass(env, "HelloWorld")
    // connect to class "Java/lang/Class"
    classClass = (*env)->FindClass(env, "java/lang/Class")
    // get the id of Class.forName method
    forNameID = (*env)->GetStaticMethodID(env, classClass, "forName", "(Ljava/lang/String;)Ljava/lang/Class;")
    // j name of HelloWorld
    jClassName = (*env)->NewStringUTF(env, "HelloWorld")
    // call forName -> fails
    jClassObject = (*env)->CallStaticObjectMethod(env, classClass, forNameID, jClassName)
         -----> Exception in thread "Thread-4" java.lang.ClassNotFoundException: HelloWorld
              at java.lang.Class.forName0(Native Method)
              at java.lang.Class.forName(Class.java:217)
    Sustem: MacOSX 10.2.8
    Java Version: 1.4.1
    $CLASSPATH env var: /System/Library/Frameworks/JavaVM.framework/Versions/1.4.1/Classes
    Can somebody help me or point me to some useful URL about this?
    Thanks

    Here is a simple app that demonstrates my problem. I compiled and ran it on MacOSX but I have the same problem on windows. Copy the following code in a file named "javatest.c", cd to that directory and compile it with commad:
    gcc -o javatest javatest.c -framework JavaVMthen run it with:
    ./javatestCode:
    #include <JavaVM/jni.h>
    //===========================================================================================
    static void print_exception(JNIEnv *envP)
         // output the exception
         if (envP && ((*envP)->ExceptionOccurred(envP) != NULL))
         {     (*envP)->ExceptionDescribe(envP);
              (*envP)->ExceptionClear(envP);
    //===========================================================================================
    int main()
    JavaVMInitArgs     vm_args;
    JavaVM               *jvm;
    JavaVMOption        options[5];
    char               *classPathEnv;
    char               *classPathString;
    jint               res;
    JNIEnv                *envP = NULL;
    jclass               jlcClass;
    jmethodID          forNameID;
    jstring               jClassName;
    jobject               jClassObject;
         vm_args.version = JNI_VERSION_1_2;
         // options
         vm_args.nOptions = 5;
         options[0].optionString = "-verbose:class" ;
         options[1].optionString = "-verbose:jni" ;
         options[2].optionString = "-verbose:gc" ;
         classPathEnv = (char *)getenv( "CLASSPATH" );
         if (!(classPathString = (char*)malloc(strlen( "-Djava.class.path=" ) + strlen(classPathEnv) + 1)))
    printf("malloc failed\n");
              exit(1);
         sprintf(classPathString, "%s%s" ,"-Djava.class.path=" , classPathEnv);
         options[3].optionString = classPathString;
         options[4].optionString = "vfprintf" ;
         options[4].extraInfo = vfprintf;
         vm_args.options = options;
         vm_args.ignoreUnrecognized = JNI_FALSE;
         // Load the jvm
         res = JNI_CreateJavaVM(&jvm, (void**)&envP, &vm_args);
         if (res != JNI_OK)
         {     printf("CreateJavaVM failed\n");
              exit(1);
         // find the class "java/lang/Class"
         if (!(jlcClass = (*envP)->FindClass(envP, "java/lang/Class")))
         {     printf("FindClass java/lang/Class failed\n");
              print_exception(envP);
              exit(1);
         // find the method ID of Class.forName
         if (!(forNameID = (*envP)->GetStaticMethodID(envP, jlcClass, "forName", "(Ljava/lang/String;)Ljava/lang/Class;")))
         {     printf("GetStaticMethodID forName failed\n");
              print_exception(envP);
              exit(1);
         // make a java string of my "HelloWorld" class
         if (!(jClassName = (*envP)->NewStringUTF(envP, "HelloWorld")))
         {     printf("NewStringUTF failed\n");
              print_exception(envP);
              exit(1);
         // call method Class.forName
         if (!(jClassObject = (*envP)->CallStaticObjectMethod(envP, jlcClass, forNameID, jClassName)))
         {     printf("CallStaticObjectMethod of forName failed\n");
              print_exception(envP);
              exit(1);
         // fail with:
         // java.lang.ClassNotFoundException: HelloWorld
         //        at java.lang.Class.forName0(Native Method)
         //        at java.lang.Class.forName(Class.java:115)
    return 0;
    }HelloWorld java code (compiled in a .class file located in $CLASSPATH folder):
    public class HelloWorld
         public static void main (String args[]) throws Exception
              System.out.println ("HelloWorld");
    }Someone can help me about this?

  • Question about Class.forName()

    I am trying to get an instance of a class by its name. Now, I have tried both creating it with the class's actual name and with the class's name including the package path and both times I got a java.lang.ClassNotFoundException: my/package/MyClass.
    I am reading the name out of a properties file and that's working just fine according to my logging information btu here is the code anyway:
    Properties prop = new Properties();
    try{
         java.io.FileInputStream in = new java.io.FileInputStream(inv.getPath());
         prop.load(in);
         String temp = prop.getProperty("myclass1");
         Class c = Class.forName(temp);
         rollen.put("user",c.newInstance());
         temp = prop.getProperty("myclass2");
         c = Class.forName(temp);
         rollen.put("admin",c.newInstance());
    }catch(Exception e){
         //I'm doing some more logging here, guess that's not very interesting
    }I deleted all the logging info from this code snippet to make it shorter. But I can tell you that the name does get read out as my.package.MyClass - and the package and class name are correct...
    The entries in the properties files look like this:
    myclass1=my.package.MyClass
    myclass2=my.package.MyOtherClass
    Can you help me fix this, please?

    Is your classpath okay? I tried this:
    pkg\MyClass.javapackage pkg;
    public class MyClass {
        public MyClass () {
            System.out.println ("Woohoo!");
    }Test.javapublic class Test {
        public static void main (String[] parameters) throws Exception {
            Class.forName ("pkg.MyClass").newInstance ();
    }This outputsWoohoo!as expected.
    Kind regards,
      Levi

  • Why use Class.forName() ?

    Why is it always adviced to use Class.forName( nameOfTheDriver ). Why dont we simply import the driver via the import statement ?
    Please note that this topic is part of a bigger topic I published in Java programming about difficulties I had importing driver. See:
    http://forums.java.sun.com/thread.jsp?forum=31&thread=147534
    for more details.

    Because using an import statement only tells the compiler about the driver. Class.forName() actually loads the driver when the program runs, which is what you want to happen.

  • Diffrence between Class.forName() and new Operator

    What is diffrence between class.forName() and new operator.Please tell in much detail.
    Also about classloader.loadclass.
    Suppose the class that we are tring to load with the help of class.forname is not compiled. Again if I make changes at runtime to that class will that get reflected.

    What is diffrence between class.forName() and new
    operator.Please tell in much detail.Class.forName loads a class. The new operator creates a new instance. Apple trees and apples.
    Also about classloader.loadclass.Read the API.
    Suppose the class that we are tring to load with the
    help of class.forname is not compiled.Then you can't load it and get an exception. Read the API.
    Again if I
    make changes at runtime to that class will that get
    reflected.Depends on the changes and when exactly you do them.

  • How to use class.forName

    I am trying to use Class.forName() from a string which is passed to me as argument.
    Class batchClass = Class.forName(args[1]);
    A jar file contains the class file for the string received above and I have this jar file in the manifest of my executable jar.
    I get a class not found exception when I run my executable jar
    Can some body give pointers..what could possibly be the issue.
    The jar file is in my classpath
    run script
    #!/bin/csh
    java -jar -DDBPROVIDER=NO -DDBUS_ROOT=$DBUS_ROOT -DVTNAME=$VTNAME ./jar/IntraDayDepotPositionBatch.jar MagellanStart IntraDayDepotPositionBatch INPUTFILE LOGFILE
    Exception
    Magellan program starting - program class IntraDayDepotPositionBatch
    Cannot find program class - IntraDayDepotPositionBatch
    IntraDayDepotPositionBatch
    java.lang.ClassNotFoundException: IntraDayDepotPositionBatch
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at com.db.mmrepo.app.IntraDayDepotPositionBatch.MagellanStart.main(Unknown Source)
    Thanks for your time and feedback on this

    actually i tried both...with package name and without package name..
    nothing worked...
    my manifest file also contains the path to the package..so does the classpath

  • Not able to work with Class.forName

    I am trying to use Class.forName() from a string which is passed to me as argument.
    Class batchClass = Class.forName(args[1]);
    A jar file contains the class file for the string received above and I have this jar file in the manifest of my executable jar.
    I get a class not found exception when I run my executable jar
    Can some body give pointers..what could possibly be the issue.
    The jar file is in my classpath
    Message was edited by:
    chabhi

    run script
    #!/bin/csh
    java -jar -DDBPROVIDER=NO -DDBUS_ROOT=$DBUS_ROOT -DVTNAME=$VTNAME ./jar/IntraDayDepotPositionBatch.jar MagellanStart IntraDayDepotPositionBatch INPUTFILE LOGFILE
    Exception
    Magellan program starting - program class IntraDayDepotPositionBatch
    Cannot find program class - IntraDayDepotPositionBatch
    IntraDayDepotPositionBatch
    java.lang.ClassNotFoundException: IntraDayDepotPositionBatch
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at com.db.mmrepo.app.IntraDayDepotPositionBatch.MagellanStart.main(Unknown Source)
    THanks for your time on this issue,,,,

  • Weblogic is getting shutdown by calling Class.forName("className")

    Hi,
    I have written the following code and it's running thru a web application in Weblogic. The problem is when calling Class.forName(), the weblogic server 9.2 gets shutdown.
    final static private String[] uib_cn = {
    "com.realm.portal.cda.ui.UIBuilder",
    "com.realm.rcash.rcoll.cda.ui.RCollUIBuilder",
    "com.realm.rcash.rpay.cda.ui.RPayUIBuilder"
    static {
    // Init the Constructor object for each UI builder class
    for (int i = 0; i <uib_cn.length; i++) {
    try {
    Class<?> c = Class.forName(uib_cn);
    uic[i] = c.getConstructor(IRbacParamsBean.class);
    } catch (Exception e) {
    log.error(e.getMessage(), e);
    The class containing this code in a jar file, is trying to load at runtime other class files which are in separate jar but all the jars are in same location WEB-INF/lib.
    Plz anyone can help me why this is happening and how to resolve this?
    Thanks & Regards
    Chanchal

    Is it due to an unhandled exception in the static initializer block? Are those classes available?

Maybe you are looking for

  • Facing a Problem while downloading the data from ALV Grid to Excel Sheet

    Hi Friends, Iam facing a problem while downloading the data from ALV Grid to excel sheet. This is working fine in Development server , when comes to Quality and Production servers I have this trouble.    I have nearly 11 fields in ALV Grid and out of

  • How to kill an instance process in BPM studio 6.0

    Hi i'm Fabio. I'm working on BPM Studio 6.0 and i need to complete a task. I have an instance id process, and i need to create a new process in order to kill this istance id. I read how to create a PAPI client (http://download.oracle.com/docs/cd/E131

  • Solaris 10 Live Upgrade with Veritas Volume Manager 4.1

    What is the latest version of Live Upgrade? I need to upgrade our systems from Solaris 8 to Solaris 10. All our systems have Veritas VxVM 4.1, with the O.S disks encapsulated and mirrored. Whats the best way to do the Live Upgrade. Anyone have clean

  • Cannot install into new laptop

    I upgraded to a new laptop and uninstalled CS 6 from the old. Now I cannot install into the new laptop.

  • Adobe fail when open .pdf documents with IE browser

    It happened when I open .pdf with IE browser, IE will freezes. Who know how to solve ? I used IE 7.0 and adobe reader 8.x here picture: http://freedictionarysoftware.info/images/error.JPG