How to load a class , which isn't in the classpath environment variable.

Hi, you folks.
I have one problem. I want to load a class, which isn't in the classpath
environment variable and I don't want to put into classpath. which method
JVM can use to load it?
Waitting for your sage advice.
Regareds
Hunter.Xiao

You will have to write your own ClassLoader, or use something like URLClassLoader (I've never used this myself, but I've seen it mentioned elsewhere in this forum). Look here.

Similar Messages

  • How to execute a class wich is not in the classpath

    Sometime the server can't be shutdown and, if You add some new classes to Your system there's a classpath problem : in the classpath OC4J doesn't see new classes
    How can we solve that problem ?
    Is it possible to execute something wich is not in the classpath ?
    Can the classpath be changed at runtime ?
    TIA
    Tullio

    Please look at the following paper http://otn.oracle.com/tech/java/oc4j/pdf/ClassLoadingInOC4J_WP.pdf
    tha describes how does classloading work in OC4J.
    You can deploy application using opn expanded directory structure if you are using OC4J standalone.
    Also you donot have to restart the server when classes are changed, you have to touch the application.xml for your application or web.xml for Web module to redeploy the apps.
    regards
    debu

  • How to load a class dynamically (via reflection) in a jsf-component

    Hi all,
    I am writing my own jsf component and I would like to do it generically. Therefore I have an attribute, where the developer can pass a fully qualified classname, which I want to use to instantiate. But I have a Problem with the classloaders, everytime I get a ClassNotFound-Exception during debugging.
    Does anybody know how it is possible, to to get the most parent classloader?
    Currently I am even not able to load a class, which is in the same package like all other compontent-classes.
    Thank you very much in advance
    Thomas

    Within web applications, I believe it is recommended to use Thread.getContextClassLoader(). Keep in mind that web applications require different classloader semantics than regular Java applications. The class loader which gets resources from the WAR is favored over others, even when this violates the normal class loading conventions.

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • How to Load a class manually

    Hello Friends,
    I need a help regarding how to load a class manually.
    i have the class name -- TestClass1
    and Path - com.apps.classes
    Thank you

    Thank You------
    I got the result
    String classPath = com.apps.className;
    Object obj = Class.forName(classPath).newInstance();

  • Loading a class via reflection without knowing the full qualified path ?

    Hi there
    I d like to load a class via reflection and call the constructor of the class object. My problem is that I dont know the full qulified name e.g. org.xyz.Classname bur only the Classname.
    I tried different things but none seem to work:
         1. Class c = Class.forName("Classname");  //does not suffice, full qualified name required
    2. ClassLoader classloader = java.lang.ClassLoader.getSystemClassLoader();
             try {
               Class cl = classloader.loadClass(stripFileType(Filename));//if i do not pass the full qualified name i get a ClassNotFoundException
    3. I tried to consruct a class object with my own classloader , calling:
              Class cl = super.defineClass(null, b, 0, b.length );     b is of type byte[]This almost works. I get a class Object without knowing the full qulified path. I can transform a filename into a raw array of bytes and I get the class out of it. But there is still a problem: If there are more than on classes defined in the same textfile I get an InvocationTargetException.
    It looks like this:
    package org.eml.adaptiveUI.demo;
    import com.borland.jbcl.layout.*;
    import java.awt.*;
    import org.eml.adaptiveUI.layout.*;
    import javax.swing.*;
    import java.awt.event.*;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2003</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class twoButtons extends JFrame {
      SPanel sPanel1 = new SPanel();
      JButton jButton1 = new JButton();
      GridBagLayout gridBagLayout1 = new GridBagLayout();
      GridBagLayout gridBagLayout2 = new GridBagLayout();
      public twoButtons() throws HeadlessException {
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      public static void main(String args[]){
        twoButtons twob = new twoButtons();
        twob.pack();
        twob.show();
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(gridBagLayout1);
        jButton1.setText("button 1");
        jButton1.addActionListener(new TransformationDemo_jButton1_actionAdapter(this));
        this.getContentPane().add(sPanel1,  new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0
                ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(57, 52, 94, 108), 35, 44));
        sPanel1.add(jButton1,  new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
                ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 41, 0, 0), 0, 0));
      void jButton1_actionPerformed(ActionEvent e) {
        System.out.println("button 1 source: " + e.getSource());
        System.out.println("d: " + e.getID());
       System.out.println("/n commmand: " + e.getActionCommand());
    class TransformationDemo_jButton1_actionAdapter implements java.awt.event.ActionListener {
      twoButtons adaptee;
      TransformationDemo_jButton1_actionAdapter(twoButtons adaptee) {
        this.adaptee = adaptee;
      public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }As you can see there is the class TransformationDemo_jButton1_actionAdapter class defined in the same classfile. The problem is now that the twoButtons constructor calls the TransfomationDemo_jButton1_actionAdapter constructor and this leads to InvocationTargetException. I dont know if this is a java bug because it should be possible.
    Can you help me?

    hi thanks at first,
    the thing you mentioned could be a problem, but I dont think it is.
    If I have the full qualified name (which I havent) then everything goes normal. I only have to load the "twoButtons" class and not the other (actionadapter class), so I dont think this is the point. In this case the twoButtons constructor constructs an object of the actionadapter class and everything goes well. The bad thing is though that I do not have the full qulified name :(
    Invocation target exception tells me (in own words): Tried to acces the constructor of the actionadapter class (which is not public) out of class reflectionTest class .
    reflectionTest is the class where the reflection stuff happens and the twoButttons class is defineClass() ed.
    The problem is, only twoButtons class has the rights to call methods from the actionadapter class, the reflection class does not. BUT: I do not call the actionadapter methods from the reflection class. I call them only from the twoButtons class.
    I hope somebody understands my problem :)

  • My friend synced a video to my ipod but it erased all my data on my ipod,but i cant figure out how to load my old libray back without deleting the movie. my friend cant tell me the password. How can I get my old library back without deleting the movie?

    My friend synced a video to my ipod but it earased all my data on my ipod,but I can't figure out how to load my old library back without deleting the movie. My friend shares a family account so she can't tell me the password. How can i get my old library back without deleting the movie?

    Linnwarner wrote:
    She does have the right because she bought the movie.
    Not true at all.
    You only buy the right to your own personal use.
    You do NOT have the right to distribute to others.
    This is illegal.  There is no doubt about it

  • How to validate multiple lines which is exist in the form builder at the same session

    Hi All,
    we are working on oracle Forms personalization to trigger the message at the point of saving multiple lines rather than requiring each line to be save individually. Currently the oracle form is allowing to user to enter two distinct lines that have same resource and basis type in BOM.
    Currently the Oracle form is allowing to enter the duplicate combination and not giving any error message even we enter the same combination of data.
    As per the customer requirement, they don’t want to validate the data while creating the records but when they try to save the form, in that case it should validate all the records at a time then need to display the appropriate message.
    Customer don’t want to customize the Oracle standard form. Here we have only option to use form personalization or through custom.pll.
    Any idea on how to validate multiple lines which is exist in the form builder at the same session as before inserting the record itself need to perform the validations for all the records.
    Thanks for your help in this regard.
    Regards,
    Thirupathi

    you can write a post script which will do the necessary tasks.
    I mean, once you are done with inserting records into these tables, exeute another procedure which will insert these "extra" records, based on some logic.
    you may not be able use DB trigger as it may generate mutating error or if you don't write it carefully, it will go into recursive loops as you are refering to same tables.
    HTH

  • I have a WRT54G ver 7 which isn't in the download list?? Is it AOSS compatible?

    I have a WRT54G ver 7 which isn't in the download list ?? Is it AOSS compatible?

    Check the firmware on ftp://linksys.com/pub/network  ...... download the latest firmware & upgrade the router ....

  • Does anyone know how to load ACR presets when using ACR in the creative cloud?

    Does anyone know how to load ACR presets when using ACR in the creative cloud?

    Moving the discussion to Adobe Camera Raw forum.
    Thanks,
    Atul Saini

  • Am using short keyboard.  Don't know how to create plus sign which is not on the keyboard. Advice would be much appreciated.

    Am using short keyboard.  Don't know how to create plus sign which is not on the keyboard. There is no number pad. Advice would be much appreciated.

    nicholasmitaka-shi wrote:
    This is a Japanese kana input keyboard, A1242, whioch looks quite as usual except that a few functions have no space on the board and have been ommitted. 
    Is the plus sign really not available on your keyboard at the place indicated on this graphic (to the right of the L key)? You might need to use shift or alt/option or shift+alt/option.
    http://en.wikipedia.org/wiki/File:KB_Japanese.svg

  • Whats in the full feature driver & software download for officejet pro8600 which isn't in the basic?

    Does anyone know what is in the full feature driver & software download V28.8  or for any version really other version for the matter for Officejet pro8600 ......which isn't in the basic download?
    I'm running vista on an old computer and it doesn't have service pack 2 on it, which is needed for the full download feature download.
    Just wondering if its worth installing service pack 2 to get better features.
    Cheers 
    This question was solved.
    View Solution.

    Hi,
    For Windows Vsita any service pack is supported and you are not required to install a service pack to install the Full Feature Software, Only Windows XP require atleast Service Pack 2..
    You may find the system requirements listed below:
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c02858465&cc=us&dlc=en&lang=en&lc=en&product=432...
    The most important feature of the Full Feature Software is the Read Iris OCR which allow scanning to editable text or searchable PDF..
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • How to load  2 records out of 4records to the  datasource....

    how to load  2 records out of 4records to the  datasource....

    Hi
    when you execute the Infopackage of the datasource, restrict the selection screen to only those 2 records
    Regards

  • Which jar file for the classpath ?

    At my office on my machine i have weblogic 8.1 and tomcat installed.
    weblogic have 2.3 version of servlet and
    tomcat have 2.4 version of servlet
    weblogic is for production purpose (development of servlet, jsp and ejb)
    and tomcat is for my own practice. (just for servlet and jsp)
    i have weblogic.jar as well as servlet-api.jar in my class path.
    now when i compile my servlets which jar file the compiler will use to create the classes.
    if the compiler chooses servlet-api.jar will my servlet run in weblogic
    else
    if the compiler chooses weblogic.jar will my servlet run in tomcat

    i have weblogic.jar as well as servlet-api.jar in my class path.What does this mean? Do you have a system CLASSPATH environment variable?
    Bad idea.
    now when i compile my servlets which jar file the
    compiler will use to create the classes.You should set CLASSPATH using the -classpath option on javac.exe.
    The compiler won't "choose" anything, because it has no idea how you'll deploy. It'll use the one that you tell it to. If you have just a system CLASSPATH it'll always use the first JAR that it finds with the packages it needs.
    You need to specify exactly what you want the compiler to use.
    In the case of servlet.jar it might not matter, because that's pretty standard. JSPs and EJBs are another story, however. If you change deployment, it's best to recompile and repackage the Web app.
    Learn Ant. It'll help you automate this.
    %

  • How to load a .class file dynamically?

    Hello World ;)
    Does anyone know, how I can create an object of a class, that was compiled during the runtime?
    The facts:
    - The user puts a grammar in. Saved to file. ANTLR generates Scanner and Parser (Java Code .java)
    - I compile these file, so XYScanner.class and XYParser.class are available.
    - Now I want to create an object of XYScanner (the classnames are not fixed, but I know the filename). I tried to call the constructor of XYScanner (using reflection) but nothing works and now I am really despaired!
    Isn't there any way to instantiate the class in a way like
    Class c = Class.forName("/home/mark/XYScanner");
    c scan = new c("input.txt");
    The normal call would be:
    XYLexer lex = new XYLexer(new ANTLRFileStream("input.txt"));The problem using reflection is now that the parameter is a ANTLRFileStream, not only an Integer, as in this example shown:
    Class cls = Class.forName("method2");
    Class partypes[] = new Class[2];
    partypes[0] = Integer.TYPE;
    partypes[1] = Integer.TYPE;
    Method meth = cls.getMethod("add", partypes);
    method2 methobj = new method2();
    Object arglist[] = new Object[2];
    arglist[0] = new Integer(37);
    arglist[1] = new Integer(47);
    Object retobj = meth.invoke(methobj, arglist);
    Integer retval = (Integer)retobj;
    System.out.println(retval.intValue());Has anyone an idea? Thanks for each comment in advance!!!

    Dump all of your class files into a directory.
    Use the File class to list all files and iterateover
    the files.NastyNot really, when you are dynamically creating code, I would expect the output to be centralized, not spread out all over the place.
    >
    Use a URLClassloader to load the URL that isobtained
    for each file with file.toURI().toURL()(file.toURL()
    is depricated in 1.6)Wrong, the URL you give it must be that of the
    directory, not the class file.No, I did this quite recently, you can give it a specific class file to load.
    >
    Load all of the classes in this directory, thatway
    any anonymous classes are loaded as well.Anonymous classes automatically loaded when the real
    one isIt can't load it if it doesn't know where the code is. Since you haven't used a URL classloader to load once class file at a time, you would never encounter this. But if you loaded a class file that had an anonymous classfile it needed, would it know where to look for it?
    >
    From this point you should be able to just get a
    class with Class.forName(name)No. Class.forName uses the classloader of the class
    it's called in, which will be the system classloader.
    It won't find classes loaded by a URLClassLoader.got me there.

Maybe you are looking for

  • Multiple Reconcilation Accounts

    Hi gurus I am getting one problem. As i am maintained Multiple alternative reconcilation accounts to vendor/customer. Because at the invoice posting i want select suitable reconcilation account. But the Reconcilation account field was displed as non-

  • Details for payment ...not regularized yet?

    I just updated my details for payment and my previous plan is not regularized yet? what do i have to do more? i save the new content. I think that is what only needs to be done, from the looks of the information in the page... someone please help?

  • I can't convert songs into ringtones

    Yesterday, I had 50 songs that I could convert now I have none. I tried changing Rockstar by Nickelback and Crazy by Gnarls Barkley. Yesterday, they were both convertable, now there not.

  • How to edit classpath for Domain Admin Server?

    Hi! Please, explain me how can I edit the classpath settings for Domain Admin Server of Sun java Application Server 8.2? I need to remove some classpath made by application installer in order to make the application work. It is said in documentation

  • New MacBook Pro or stick with what I love?

    Hi- I jumped back into the world of Apple with a 15" MacBook Pro purchase in July of 2007.  Absolutely love this computer.  One thing I have taken advantage of over the years is the ability to do the following: -Upgrade the RAM memory. -Upgrade the H