Class creation at Runtime?

Hi,
How can I create a class at Runtime? I want to create multiple classes having structure (say):
public class MyClass{
   public void myMethod(){
        System.out.println("Some Text")
}Now I want to create multiple classes at runtime having name "MyClass1.class", "MyClass2.class", ......
Please Help.
Thanks,
Sumit

Actually, I want those multiple classes
("Myclass1.class", "Myclass2.class".....) to be
present physically on the machine. As some other
program then going to load those classes later on.
Any Solution?How about defining a single class, whose instances can be described with a standard set of data. Say, that data could be represented by java.util.Properties object, and this class will have a constructor that takes a Properties as an argument.
Then this other program will load files in the format used by Properties, then it will use Properties.load() to load the data from these files, and then instantiate the class. Rather than loading lots of different classes.
Or not. It's up to you.

Similar Messages

  • Loading class oracle/jpub/runtime/dbws/DbwsProxy into the database

    I am trying to create a Database Web Services call-out in PL/SQL, however, encountered error "ORA-29540: class oracle/jpub/runtime/dbws/DbwsProxy does not exist". I followed some steps to load utl_dbws.jar, utl_dbws_jserver.jar and dbwsclient.jar into the database, but still getting the same error saying DbwsProxy class does not exist. This is very frustrating and I do not know how to fix this. I tried to just load DbwsProxy.class into the database and it executed successfully, however, the database is still complaining that oracle/jpub/runtime/dbws/DbwsProxy does not exist. Does anyone has any idea what's going on? Thanks much. I am cracking my brain out here.

    This is the error message I received when loading:
    The following operations failed
    class java/lang/NumberFormatException: creation (createFailed)
    class java/lang/Number: creation (createFailed)
    class java/lang/Object: creation (createFailed)
    class java/lang/String: creation (createFailed)
    class java/lang/Long: creation (createFailed)
    exiting : Failures occurred during processing
    This is the error message I received in the database after loading dbwsclient.jar:
    ERROR at line 1:
    ORA-29540: class oracle/jpub/runtime/dbws/DbwsProxy does not exist
    ORA-06512: at "SYS.UTL_DBWS", line 135
    ORA-06512: at "SYS.UTL_DBWS", line 132
    ORA-06512: at "MICHELLE.MICH", line 8
    ORA-06512: at line 1
    So that class is still missing. You were suspecting that this class is not loaded successfully into the database? Is it possible for me to just load that particular class into the database?
    Thanks.

  • Class oracle/jpub/runtime/dbws/DbwsProxy does not exists on 10g Rel2

    I trying using UTL_DBWS with samle from url http://www.freelists.org/archives/oracle-l/03-2005/msg00670.html in 10g Rel2 but I take error: class oracle/jpub/runtime/dbws/DbwsProxy does not exists .What I do incorrect?
    However, using web service in Oracle rdms very hard...May be exists simply example for dummies?

    Not really for dummies, but it may be a good way to get started:
    Oracle Database Programming Using Java and Web Services, by Kuassi Mensah.
    You have also the following resouces on OTN: Database Web Services.
    -- Eric

  • ORA-29540: class oracle/jpub/runtime/dbws/DbwsProxy does not exist

    Hi ,
    We are getting below error while executing webservice from PL/SQL block. Please help what would be wrong in below code. Thanks in advance.
    ORA-29540: class oracle/jpub/runtime/dbws/DbwsProxy does not exist
    ORA-06512: at "SYS.UTL_DBWS", line 318
    ORA-06512: at "FUSION.ADD_NUMBERS", line 21
    29540. 00000 - "class %s does not exist"
    *Cause:    Java method execution failed to find a class with the indicated name.
    *Action:   Correct the name or add the missing Java class.
    PL/SQL Code
    CREATE OR REPLACE FUNCTION add_numbers (username IN VARCHAR, password IN VARCHAR)
    RETURN NUMBER
    AS
    l_service SYS.UTL_DBWS.service;
    l_call SYS.UTL_DBWS.call;
    l_wsdl_url VARCHAR2(32767);
    l_namespace VARCHAR2(32767);
    l_service_qname SYS.UTL_DBWS.qname;
    l_port_qname SYS.UTL_DBWS.qname;
    l_operation_qname SYS.UTL_DBWS.qname;
    l_xmltype_in SYS.XMLTYPE;
    l_xmltype_out SYS.XMLTYPE;
    l_return NUMBER;
    returnVal BOOLEAN;
    boolean_type_qname sys.utl_dbws.QNAME;
    string_type_qname sys.utl_dbws.QNAME;
    BEGIN
    sys.UTL_DBWS.SET_PROPERTY(l_call,'USERNAME','fusion');
    sys.UTL_DBWS.SET_PROPERTY(l_call,'PASSWORD','fusion');
    l_wsdl_url := 'http://adcdab06.us.oracle.com:10217/xmlpserver/services/PublicReportWSSService?wsdl';
    l_namespace := 'http://xmlns.oracle.com/oxp/service/PublicReportService/';
    l_service_qname := SYS.UTL_DBWS.to_qname(l_namespace, 'PublicReportWSSServiceService');
    l_port_qname := SYS.UTL_DBWS.to_qname(l_namespace, 'PublicReportWSSService');
    l_operation_qname := SYS.UTL_DBWS.to_qname(l_namespace, 'validateLogin');
    l_service := SYS.UTL_DBWS.create_service (URIFACTORY.getURI(l_wsdl_url),l_service_qname);
    l_call := SYS.UTL_DBWS.create_call (l_service,l_port_qname,l_operation_qname);
    sys.utl_dbws.set_target_endpoint_address(l_call, 'http://adcdab06.us.oracle.com:10217/xmlpserver/services/PublicReportWSSService');
    boolean_type_qname :=sys.utl_dbws.to_qname ('http://www.w3.org/2001/XMLSchema', 'boolean');
    string_type_qname :=sys.utl_dbws.to_qname ('http://www.w3.org/2001/XMLSchema', 'string');
    sys.utl_dbws.add_parameter(l_call, 'BI_Admin', string_type_qname, 'ParameterMode.IN');
    sys.utl_dbws.add_parameter(l_call, 'Welcome1', string_type_qname, 'ParameterMode.IN');
    -- sys.utl_dbws.add_parameter (l_call,returnVal,boolean_type_qname,'ParameterMode.OUT');
    sys.utl_dbws.set_return_type (l_call, string_type_qname);
    -- utl_dbws.add_parameter(l_call_, 'ubiNum', string_type_qname, 'ParameterMode.IN');
    --sys.utl_dbws.add_parameter(l_call, 'TEST', string_type_qname, 'ParameterMode.IN');
    --l_xmltype_in := SYS.XMLTYPE('<?xml version="1.0" encoding="utf-8"?>
    --<validateLogin xmlns="' || l_namespace || '">
    --<validateLoginInput>' || p_int_1 || '</validateLoginInput>
    --</validateLogin>');
    l_xmltype_out := SYS.UTL_DBWS.invoke(call_Handle => l_call, request => l_xmltype_in);
    SYS.UTL_DBWS.release_call (call_handle => l_call);
    SYS.UTL_DBWS.release_service (service_handle => l_service);
    dbms_output.put_line('WS Executed successfully...');
    -- l_return := l_xmltype_out.extract('//return/text()').getNumberVal();
    RETURN 11;
    END;
    /

    Check if this helps:
    ORA-29540: class oracle/jpub/runtime/dbws/DbwsProxy does not exist

  • ABAP class creation

    I would like to know what is ABAP class creation (Table API). Also would like to know how is it related to SAP BW reports.

    Are you talking about creating a ABAP class via SE24?
    Regards,
    Rich Heilman

  • ORA-29540:class oracle/pub/runtime/dbws/DbwsProxy does not exist

    Hi we are getting below error while calling UTl_DBWS package.
    Database version 11.2.0.2
    package definition
    create or replace function xxpvn_ws_test
    return varchar2
    is
      service_           sys.utl_dbws.SERVICE;
      call_              sys.utl_dbws.CALL;
      service_qname      sys.utl_dbws.QNAME;
      port_qname         sys.utl_dbws.QNAME;
      xoperation_qname   sys.utl_dbws.QNAME;
      xstring_type_qname sys.utl_dbws.QNAME;
      response           sys.xmltype;
      request            sys.xmltype;
    begin
      service_qname := sys.utl_dbws.to_qname(null, 'getJoke');
      service_ := sys.utl_dbws.create_service(service_qname);
      call_ := sys.utl_dbws.create_call(service_);
      sys.utl_dbws.set_target_endpoint_address(call_, 'http://interpressfact.net/webservices/getjoke.asmx');
      sys.utl_dbws.set_property( call_, 'SOAPACTION_USE', 'TRUE');
      sys.utl_dbws.set_property( call_, 'SOAPACTION_URI', 'http://interpressfact.net/webservices/getJoke');
      sys.utl_dbws.set_property( call_, 'OPERATION_STYLE', 'document');
      request := sys.xmltype(
           '<getJoke xmlns="http://interpressfact.net/webservices/">'
        || '<Category>Excuses-10</Category>'
        || '</getJoke>');
      response :=sys. utl_dbws.invoke(call_, request);
      return response.extract('//getJokeResult/child::text()',
        'xmlns="http://interpressfact.net/webservices/"').getstringval();
    end ;error message
    SQL> select xxpvn_ws_test from dual;
    select xxpvn_ws_test from dual
    ERROR at line 1:
    ORA-29540: class oracle/jpub/runtime/dbws/DbwsProxy does not exist
    ORA-06512: at "SYS.UTL_DBWS", line 144
    ORA-06512: at "SYS.XXPVN_WS_TEST", line 14
    Thanks
    Jitendra

    This error related to jave since its not installed in database user schema
    Logout of sqlplus and run:
    loadjava -u / -r -v -f -s -grant public -genmissing dbwsclientws.jar dbwsclientdb102.jar
    Check this
    https://kr.forums.oracle.com/forums/thread.jspa?threadID=2264325

  • Root cause for  class oracle/jpub/runtime/dbws/DbwsProxy does not exist

    Hi,
    I am trying to use UTL_DBWS to call a webservice, adn getting a error " ORA-29540: class oracle/jpub/runtime/dbws/DbwsProxy does not exist "
    its going back and forth between me and operations , I aske them to load the package but still the script fails. Is there any way to confirm whether the package is loaded , like the below script
    as sys:
    select status from all_objects where
    dbms_java.longname(object_name)='oracle/jpub/runtime/dbws/DbwsProxy';
    Please help to find the root cause

    Please check if you have the grants on UTL_DBWS.

  • Error: cannot access class oracle.jsp.runtime.HttpJsp; file oracle\jsp\runtime\HttpJs

    Hello,
    where is now oracle\jsp\runtime\HttpJsp.class located?
    thanks.
    Oleg.

    Same problem,
    Error: cannot access class oracle.jsp.runtime.HttpJsp; file oracle\jsp\runtime\HttpJsp.class not found
    Thanks
    aldo

  • How to remove a static class from the Runtime of the JVM

    I want to remove a static class from the Runtime of the JVM.
    My goal is to clear the cache of the "InetAddress.getByName(String host)" static method.
    Thanks in advance.
    Floweb

    Sorry, It means a class that has been loaded in the JVM by the call to a static method......
    Floweb

  • How to find a classes attributes at runtime?

    Hi,
    I need to write a program that inspects a class and finds out what attributes it has and then converts them to an XML string. Any idea how to get the classes attributes at runtime? I want this to work with 3rd party API's hence the reason I don't just either code a toXML function in each class or have a method to return the attribute names.
    Thanks
    Andre

    Hi,
    I need to write a program that inspects a class and
    finds out what attributes it has and then converts
    them to an XML string. Any idea how to get the classes
    attributes at runtime? I want this to work with 3rd
    party API's hence the reason I don't just either code
    a toXML function in each class or have a method to
    return the attribute names.
    Thanks
    AndreYou might want to take a look at Java's reflection mechanism:
    http://java.sun.com/docs/books/tutorial/reflect/index.html

  • Dynamic Tray creation at runtime

    hi experts,
    we have a requirement where we are showing employee details in the tray UI element.
    we have 1 tray at design time showing employee details obtained from a Bapi.
    Now we need to display spouse details(if available) and children details(their number can be any~known at runtime) in seperate trays. eg each tray for 1 person..so if there are 6 children, there are 8 trays including one for employee and spouse...
    Now what I need is the source code  or method to dynamically generate tray at runtime along with the labels and textviews they contain..
    thanks in advance

    HI,
    solved the problem....
    i was doing some search here and there and finally got the code to do it. when i came back to the thread i found Ramesh suggested the same stuff which i had used.
    thanks gurus.
    I am writing my code here for other people looking for the same thing:
    IWDTransparentContainer container =(IWDTransparentContainer)view.getElement("RootUIElementContainer");
         wdContext.currentContextElement().setIpvalue("Demo Name");   //this is my context attribute.
    for(int i=1;i<3;i++)
         IWDTray tray=(IWDTray)view.createElement(IWDTray.class,null);
                   tray.setExpanded(false);
                   tray.setWidth("700px");
                   IWDLabel label=(IWDLabel)view.createElement(IWDLabel.class,null);
                   label.setText("your name is");
              IWDTextView textview1=(IWDTextView)view.createElement(IWDTextView.class,null);
              textview1.setText(wdContext.currentContextElement().getIpvalue());
              IWDLabel label1=(IWDLabel)view.createElement(IWDLabel.class,null);
              label1.setText("Employee age");
         IWDCaption caption =(IWDCaption)view.createElement(IWDCaption.class,null);
         caption.setText("WElcome to employee information");
                   tray.setHeader(caption);
         IWDLayout layout=(IWDLayout)tray.createLayout(IWDMatrixLayout.class); //setting tray layout to matrix
         IWDLayoutData layout1=(IWDLayoutData)label1.createLayoutData(IWDMatrixHeadData.class);
         tray.addChild(label);
         tray.addChild(textview1);
         tray.addChild(label1);
                   container.addChild(tray);
    P.S. Awarding points to Ramesh.

  • Dynamic class loading at runtime issues

    Hi,
    my system works by loading lots of classes located in numerous jars at runtime, it works ok but there are a few things i would like to resolve.
    1. When i come to implement an interface that is located in a jar with my IDE, the names of method variables are lost. So instead of the method having the inputs I set such as "String name, String type", i see "String s1, String s2". This is inconvinient and very error prone!
    2. If an exception is thrown in one of my dynamically loaded classes, the line at which the exception occoured at is lost. So instead of saying "some.package.FautlyClass.method(FautlyClass.java:39)" in an exception it says " some.package.FautlyClass.method(Unkown Source)". This even happens when i output a log from the class from which the exception is thrown.
    If anyone has any help/advice/solutions with these issues it would be much appreciated.
    Ck

    Most IDE's have an option, usually in the compiler preferences or project area, to "save local variable names". That should remove the "unknown source" message, but it will depend vastly on your IDE's options.
    Which IDE are you using? I've never heard of one dynamically renaming variables on the fly, unless you are specifically asking it to obfuscate your code.
    - Saish
    "My karma ran over your dogma." - Anon

  • Dynamic Report Creation At Runtime

    I am trying to create a dynamic crystal report at run time from Visual Studio 2013 using C#.  My back end database is SQL Server 2005.  The source for my crystal report is a SQL Server stored procedure which takes two parameters, a year (smallint) and a quarter (tinyint).  The stored procedure uses dynamic SQL and creates a dynamic temp table.  It returns the result set from a select on the temp table.  The number of columns in the result set will be determined at run time.  Right now it returns 40 columns.  It can return additional columns in multiples of 6.  All of these columns will need to be displayed on the crystal report at run time.  The C# application will run on 64 bit Windows 7 machines and the SQL Server database is on a 32 bit server.
    I have been successful in designing a crystal report within the Visual Studio IDE using this stored procedure and running it and displaying it in the crystal reports viewer from within the C# application.  So when the appropriate application's menu item is clicked, the form with the crystal viewer on it opens and displays the report.  So I know that I can connect to the database and display the report.  However as stated in the preceding paragraph, I need to create the crystal report at run time as the number of columns on the report will be variable.
    I have looked at the CrystalDecisions SDK and API and tried without success to do this.  I am getting errors when trying to connect to the DB through the API and am not able to retrieve the data.  I have played with the code for about a week with no success.  I have tried the code in the discussion forums without success.  The documentation for the SDK API's does not provide the level of detail that I need.  The CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo class has an attributes property that needs to be set.  I don't know what the proper settings should be.
    I prefer to use the OLE DB native client for SQL Server.
    Any help would be greatly appreciated.
    Martin

    Hi Ludek,
    I have made some small progress.  I can now login from work as well as get to links.  But it seems I am still blocked for zip files.
    I also have the utility working.  But whenever I try to add my dummy crystal report (dummyreport.rpt) to the project, visual studio 2013 hangs up and I have to kill VS.
    I added the following code to my form and ran it but I get the following error:
    System.Runtime.InteropServices.COMException was unhandled
      HResult=-2147352565
      Message=Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
      Source=CrystalDecisions.ReportAppServer.DataDefModel
      ErrorCode=-2147352565
      StackTrace:
           at CrystalDecisions.ReportAppServer.DataDefModel.TablesClass.get_Item(Int32 Index)
           at Retail_Incentive_Plan.ReportForm3..ctor() in u:\Incentive\Front_End\Visual_Studio_2013\Projects\Retail_Incentive_Plan - Copy\Retail_Incentive_Plan\ReportForm3.cs:line 123
           at Retail_Incentive_Plan.MDIParent.ShowNewForm(Object sender, EventArgs e) in u:\Incentive\Front_End\Visual_Studio_2013\Projects\Retail_Incentive_Plan - Copy\Retail_Incentive_Plan\MDIParent.cs:line 27
           at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
           at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
           at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
           at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
           at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           at System.Windows.Forms.Control.WndProc(Message& m)
           at System.Windows.Forms.ToolStrip.WndProc(Message& m)
           at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
           at Retail_Incentive_Plan.Program.Main() in u:\Incentive\Front_End\Visual_Studio_2013\Projects\Retail_Incentive_Plan - Copy\Retail_Incentive_Plan\Program.cs:line 18
      InnerException:
    The error occurs at this line of code:
    boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0], boTable);
    I'm sure it must be something with the attributes that I am setting.  But I'm not sure of what the correct values for some of these attributes should be.  By the way, I am using the RCAPI approach rather than the formulas approach (for now).
    Here is my code that is in the form:
    public ReportForm3()
    //**************************   ChangeConnectionInfo   ******************************************************************************************************************
    ReportDocument boReportDocument = new ReportDocument();
    //**EDIT** Change the path and report name to the report you want to change.
    boReportDocument.Load(@"c:\Retail_Incentive_Plan\DummyReport.rpt", OpenReportMethod.OpenReportByTempCopy);
    //Create a new Command Table to replace the reports current table.
    CrystalDecisions.ReportAppServer.DataDefModel.CommandTable boTable =
    new CrystalDecisions.ReportAppServer.DataDefModel.CommandTable();
    //boMainPropertyBag: These hold the attributes of the tables ConnectionInfo object
    PropertyBag boMainPropertyBag = new PropertyBag();
    //boInnerPropertyBag: These hold the attributes for the QE_LogonProperties
    //In the main property bag (boMainPropertyBag)
    PropertyBag boInnerPropertyBag = new PropertyBag();
    //Set the attributes for the boInnerPropertyBag
    boInnerPropertyBag.Add("Auto Translate", "-1");
    boInnerPropertyBag.Add("Server", "MyServerName");
    boInnerPropertyBag.Add("Connect Timeout", "15");
    boInnerPropertyBag.Add("Data Source", "vancsdb02");
    boInnerPropertyBag.Add("General Timeout", "0");
    boInnerPropertyBag.Add("Initial Catalog", "Retail_Incentive_Plan");
    boInnerPropertyBag.Add("Integrated Security", "True");
    boInnerPropertyBag.Add("Locale Identifier", "1033");
    boInnerPropertyBag.Add("OLE DB Services", "-5");
    boInnerPropertyBag.Add("Provider", "SQLOLEDB");
    boInnerPropertyBag.Add("Tag with column collation when possible", "0");
    boInnerPropertyBag.Add("Use DSN Default Properties", "False");
    boInnerPropertyBag.Add("Use Encryption for Data", "0");
    //Set the attributes for the boMainPropertyBag
    boMainPropertyBag.Add("Database DLL", "crdb_ado.dll");
    boMainPropertyBag.Add("QE_DatabaseName", "Initial Catalog=Retail_Incentive_Plan");
    boMainPropertyBag.Add("QE_DatabaseType", "OLE DB (ADO)");
    //Add the QE_LogonProperties we set in the boInnerPropertyBag Object
    boMainPropertyBag.Add("QE_LogonProperties", boInnerPropertyBag);
    boMainPropertyBag.Add("QE_ServerDescription", "MyServerName");
    boMainPropertyBag.Add("QE_SQLDB", "True");
    boMainPropertyBag.Add("SSO Enabled", "False");
    //Create a new ConnectionInfo object
    CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo boConnectionInfo =
    new CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo();
    //Pass the database properties to a connection info object
    boConnectionInfo.Attributes = boMainPropertyBag;
    //Set the connection kind
    boConnectionInfo.Kind = CrConnectionInfoKindEnum.crConnectionInfoKindCRQE;
    //**EDIT** Set the User Name and Password if required.
    boConnectionInfo.UserName = "myUserName";
    boConnectionInfo.Password = "MyPassword";
    //Pass the connection information to the table
    boTable.ConnectionInfo = boConnectionInfo;
    //Get the Database Tables Collection for your report
    CrystalDecisions.ReportAppServer.DataDefModel.Tables boTables;
    boTables = boReportDocument.ReportClientDocument.DatabaseController.Database.Tables;
    //For each table in the report:
    // - Set the Table Name properties.
    // - Set the Command table's command text.
    // - Set the table location in the report to use the new modified table
    boTable.Name = "Command";
    boTable.QualifiedName = "Command";
    boTable.Alias = "Command";
    //boTable.CommandText = "select country, region, city from customer where country='usa'";
    boTable.CommandText = "exec get_branch_ranking_data, 2015, 1";
    boReportDocument.ReportClientDocument.DatabaseController.SetTableLocation(boTables[0], boTable);
    //Verify the database after adding substituting the new table.
    //To ensure that the table updates properly when adding Command tables or Stored Procedures.
    boReportDocument.VerifyDatabase();
    //return boReportDocument;
    //**************************   End ChangeConnectionInfo   ***************************************************************************************************************
    I'm sure that "vancsdb02" is incorrect in the Data Source in the code above but I'm not sure what goes there.
    All of my assemblies are set in my project as well as in the top of my code.  I just didn't show it here for brevity.
    Will pick up again with this on Monday.
    Martin

  • Add jar files and use those classes at the runtime

    Hi All,
    I need to add some jar files at the runtime depends on which the user selects where the jar file is located and i need to import those classes in other class for some functionalities . I could add jar files by using the URLClassLoader and Class.forName("myjar.myclassname") is also succeeded and i have no clue how to use those classes with in the jar file as i couldn't import those classes also in the source because the jar files are being added at the runtime(This leads to class not found exception at the compile time).
    I had found a complicated way of using those classes after being added at the run time as below.
       Class clazz = Class.forName(myClass);
                final Method method = clazz.getDeclaredMethod(requiredMethod, new Class[]{URL.class});
                final Object returned = method.invoke(clazz.newInstance(), new Object[]{request}); but, its really pain to use in this way in all the places.
    Does any of you have simpler suggestions on how to achieve this?
    Thanks,
    Venky.

    Thanks jschell. Yes, you are right. I had found that using reflection API is the only way to load classes at the run time. But according to our application using reflection makes the application little complex, so while start of the application or during other modifications, i am overwriting my jar file to the latest one using FileChannel class as below
          FileChannel ic = new FileInputStream("new.jar").getChannel();
          FileChannel oc = new FileOutputStream("old.jar").getChannel();
          ic.transferTo(0, ic.size(), oc);
          ic.close();
          oc.close();After this code is executed, our application totally uses the new jar file.It is little fast than using reflection. Is this a good idea?

  • Dynamic class creation

    hi,
    I need to create new classes (not objects) dynamically in my program and then objects of that type.
    For example if the user asks to create a class with int, float & char as its data fields, and such class is not yet defined, I need to create such class and then instantiate it.
    I m creating class.java using and then compiling it using Runtime.getRuntime.exec() to get corresponding class file.
    But I m facing problem in instantiating it.
    code goes like this:
    import java.util.*;
    import java.io.*;
    public class Main {
                public Main() {
        public static void main(String[] args) {
            String key="fi";
            Hashtable hs= new Hashtable();
            if(hs.contains(key))
            else
               // hs.put(key,)
               try{
                   PrintWriter pw = new PrintWriter(new FileOutputStream(key+".java"),true);  
                  pw.println("public class "+key+"{");
                   for(int i=0; i< key.length(); i++)
                       char c = key.charAt(i);
                       switch( c )
                           case 'i' : pw.println("int i;");
                            break;
                           case 'f' : pw.println ("float f;");
                           break;
                   pw.println("public " + key + " next=null; ");
                   pw.println("public static int count=0;");
                   pw.println("public "+ key +" first=null;");
                   pw.println("public "+ key +" last=null;");
                   pw.println("public static int delta=0;");
                   pw.println("}");
                Runtime.getRuntime().exec("javac " +key+ ".java");
               catch(Exception e){e.printStackTrace();}
    //           key1 in =new key1();
               //fi in = new fi;
    }    Now after try catch block I m trying instantiate the class whose name is in key. (here key value is fi and I need create instnce of fi)

    No, The classloader associated with a class is the one that loaded it, which in the case of System.class will be the primordial class loader which "loads" classes which are actually built into the JVM. It probably won't even see the ClassPath, You'd be better putting the class files you generate on the fly into a special folder reserved for that purpose and create a URLClassLoader to load them.
    However, as has been pointed out, the question is; how are you going to use them? In general, dynamically loaded classes are only useful if they are known to implement an interface, or extend a class, available at compile time. It's pointless to create a class as a container object, for example, because if you can only access the fields through reflection it's slower, and more complicated, than using something like a HashMap.

Maybe you are looking for

  • Mac Pro 2.1 Strange HD issue

    Been Having HD issue with an early MacPro(2.1) Dual Quad core Have changed the boot disc 3 times, have reformatted the discs and reinstalled from CD on numerous occasions, then allowing time machine to restore my normal environment. Eventually i took

  • Saving Query as xls file (I have searched and havent found this problem)

    I am trying to save a query as a xls file. The user can currently save the file to there desktop but excel warns them upon opening it that the file is associated with a different type of file do you want to continue. if you choose to continue then it

  • Oo abap to get the fldcat in class

    HI friends, i have to know is their any class available to generate field catalog as like reuse_alv_fieldcataloge_merge in alv.

  • How to delete SELECT-OPTION options

    Hello, I want to know how can I delete these options (less than, greater than etc...): Anyone knows how can I disable them?

  • Database connectivity in single class

    Hi, I am currently developing an application which reads and writes to an access db. For my current problem I use three tables which reference to each other: Table 1: organization (id, name) Table 2: departments(id, name, id_of_organization) Table 3: