Packaged class reference in Reflection

Hi Everyone,
i have a package by name ABC. and inside the same i have another package DEF.
Now i have a class in ABC package , say MainClass.java.
This program by reflection is trying to get the details of a class in the Package DEF.
Let the class it is refering to be ReferredClass.
Now how should i specify the path in Class.forName to get the ReferredClass details.
Peter Iyer

Sorry Gentlemen,
It was the silliest Mistake done by me.
It should be ABC.DEF.RefferedClass
Though i used the same to get the details regarding the class , i did not use the same while i was invoking the class .. sorry people .. may be i did it in a hurry ..
Peter Iyer

Similar Messages

  • Optional Package class reference at server startup...gives class not found

    I have a enterprise app having a webservice..the webservice (servlet) gets instantiated on server startup…It has reference of a class which is an optional package
    All the manifest entries are correctly added to the ear..manifest.mf..
    When the servlet is initialized at startup.. gives me a class not found error…
    However, the app works fine..this is just a one time error(whenever the app is deployed fresh..)..
    Any help would be appreciated
    Thanks

    I have a enterprise app having a webservice..the webservice (servlet) gets instantiated on server startup…It has reference of a class which is an optional package
    All the manifest entries are correctly added to the ear..manifest.mf..
    When the servlet is initialized at startup.. gives me a class not found error…
    However, the app works fine..this is just a one time error(whenever the app is deployed fresh..)..
    Any help would be appreciated
    Thanks

  • Output error:the name of the package "greet" does not reflect the location of this file...

    output error: The name of package 'greet' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file. C:\Documents and Settings\Igal\My Documents\meiran\greet\Greeter.as
    I keep on recieving this output error although my source path is set to C:\Documents and Settings\Igal\My Documents\meiran\greet.
    any suggestions why this happens?

    The classpaths you define in your Flash software tell the compiler where to look when it needs to find a class.  According to your as file, the very top line indicates the Greeter.as file should be at a location specified by the path...
    one-of-your-classpaths\com\example\quickstart\
    So if one of your classpaths is:  C:\Documents and Settings\Igal\My Documents\meiran\greet\
    and you placed the file in the greet folder, then in your AS document you should not have the "com\example\quickstart" and your import statement in the fla should not be using that (should just be... import Greeter;)

  • Link between classes: Reference Error

    Hi,
    I am still trying to create a movie clip array to make a list of objects appear on stage and have the user interact with them.
    This will be my game loop class called "LetterArray()".
    My main class is called "BugGoopFSGame()".
    After I add the line of code below into my LetterArray(). as class file I get the error message below:
    Code entered:
    private var  lettersL1:Array = new Array[a,f,g,h,i,n,o,s,t];
    This is the error message I get:
    ReferenceError: Error #1069: Property [object T] not found on S and there is no default value.
        at LetterArray()
        at BugGoopFSGame()
    I am sure the reference I use between the two files are not good. Can you please tell me what code I should add and where.
    Thanks for your help!
    Charine
    This is the code in my main class - BugGoopFSGame()
    package
        import flash.display.*;
        import flash.utils.Timer;
        import flash.events.*;
        import flash.events.MouseEvent;
        import flash.media.Sound;
        import flash.events.Event;
        import flash.media.SoundChannel;
        import flash.media.SoundMixer;
        import flash.media.SoundTransform;
        import flash.text.*;
        import flash.net.URLRequest;
        public class BugGoopFSGame extends MovieClip
            public var mybackground:BackGround;
            public var letterArray:LetterArray = new LetterArray(stage); //this is how I link from main to gameloop
    This is the coce in my gameloop class - LetterArray()
    package
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.utils.Timer;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.net.URLRequest;
        public class LetterArray extends MovieClip
            private var _stage:Stage; //this reference works well to the main file. Should I somehow link it to the errorous code below?
            /*Movie clips that need to go into an array    */
            //level 1
            public var a:A = new A();
            public var f:F = new F();
            public var g:G = new G();
            public var h:H = new H();
            public var i:I = new I();
            public var n:N = new N();
            public var o:O = new O();
            public var s:S = new S();
            public var t:T = new T();
            private var letterArray:Array;
            private var  lettersL1:Array = new Array[a,f,g,h,i,n,o,s,t]; //this is the line that causes the error. I am sure it is because I need to add something to the main class.

    if, for example, A is a class name, you should use "A" and then use getDefinitionByName() to retrieve the class reference from the string.
    private var  lettersL1:Array = new Array['A','F','G','H','I','N','O','S','T'];
    for(var i:int=0;i<lettersL1.length;i++){
    var C:Class=Class(getDefinitionByName(lettersL1[i]));  // import flash.utils.getDefinitionByName
    var c:*=new C(); // create instances from the classes in lettersL1
    // do whatever with c
    or, move those instanciation statements into your LetterArray constructor or somewhere beyond like:
    package
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.utils.Timer;
        import flash.media.Sound;
        import flash.media.SoundChannel;
        import flash.net.URLRequest;
        public class LetterArray extends MovieClip
            private var _stage:Stage; //this reference works well to the main file. Should I somehow link it to the errorous code below?
            private var letterArray:Array;
            private var  lettersL1:Array; //this is the line that causes the error. I am sure it is because I need to add something to the main class.
            public function LetterArray(ss:Stage):void{
                var a:A = new A();
                var f:F = new F();
                 etc
                lettersL1 = [a,f,...]
                _stage = ss;

  • How to use application class reference in the controller methods of BSP

    Hi,
    I have created a bsp application and also created an application class and assigned it to the application class. In the application class, I have created attribute TEXT type string(public and instance parameter).
    In the controller let's say main.do, I am trying to give a value to to the text by adding the following code.
    application->text = 'test'.
    I am getting syntax error saying field 'text' is unknown. It is not contained in one of the specified tables nor defined by DATA statement. 
    Please can someone let me know how to use the application class in the coding with an example. I couldn't find how exactly this has to be reference. Please help.
    Best regards
    Siva

    Hi,
    if you are having main controller and sub-controller then you may need to use below coding to use application class reference.
    *Data declaration
      DATA:  obj_cntrl        TYPE REF TO cl_bsp_controller2,
             obj_sub_cntrl   TYPE REF TO z_cl_sub_cntl,
             application TYPE REF TO z_cl_application.
    *Get the controller
      CALL METHOD obj_main_cntrl->get_controller   "obj_main_cntrl is the object of main controller
        EXPORTING
          controller_id       = 'SUB'   "Controller ID
        RECEIVING
          controller_instance = obj_cntrl  .
      obj_sub_cntrl ?= obj_cntrl  .
      application ?= obj_sub_cntrl ->application.
    or simply use below code in your controller method.
      application ?= me->application.
    Thnaks,
    Chandra

  • Help! How to create Jar file for a packaged class?

    Hi!
    I am new in jar complexities. I made a swing frame that just prompts a JOptionPane when executed. I accomplished the same using jar without packaging my class SwingTest.
    But when i package it, it doesn't run. Can any one tell me how to make jar file of packaged classes and include images in the jar files too!
    Really Thanx!

    Call the Jar from the commandline to see the exceptions thrown.
    java -jar <jarFileName> <className>

  • Package Class in Transport Collector

    When i Collect my Objects in the Transport Collector, I find that many of them are attached to a different Package class. there many such sub objects too. some of them i changed by right click -> change object directory. but some 300+ objects are still residing in another package.
    CAN I change the same by updating a table called TADIR by writing an ABAP code ??
    Or shud i continue to manually change the class.
    Pls advice. thanks.

    Hi,
    if you change the object directory entry (e.g. package of an object), the SAP system is doing some more things than just changing the TADIR table: it is locking the object and connecting it to a transport request, also some checks are performed, e.g. whether the namespace of the package is allowed for the object. To avoid inconsistencies, I would <b>not</b> prefer writing an ABAP in this case.
    Stephan

  • Set fields of derived class in base class constructor via reflection?

    Does the Java Language Specification explicitly allow setting of fields of a derived class from within the base class' constructor via reflection? The following test case runs green, but I would really like to know if this Java code is compatible among different VM implementations.
    Many thanks for your feedback!
    Norman
    public class DerivedClassReflectionWorksInBaseClassConstructorTest extends TestCase {
    abstract static class A {
        A() {
            try {
                getClass().getDeclaredField("x").setInt(this, 42);
            } catch (Exception e) {
                throw new RuntimeException(e);
    static class B extends A {
        int x;
        B() {
        B(int x) {
            this.x = x;
    public void testThatItWorks() {
        assertEquals(42, new B().x);
        assertEquals(99, new B(99).x);
    }

    why not just put a method in the superclass that the subclasses can call to initialize the subclass member variable?In derived classes (which are plug-ins), clients can use a field annotation which provides some parameter metadata such as validators and the default value. The framework must set the default value of fields, before the class' initializer or constructors are called. If the framework would do this after derived class' initializer or constructors are called, they would be overwritten:
    Framework:
    public abstract class Operator {
        public abstract void initialize();
    }Plug-In:
    public class SomeOperator extends Operator {
        @Parameter(defaultValue="42", interval="[0,100)")
        double threshold;
        @Parameter(defaultValue="C", valueSet="A,B,C")
        String mode;
        public void setThreshold(double threshold) {this.threshold = threshold;}
        public void setMode(String mode) {this.mode = mode;}
        // called by the framework after default values have been set
        public void initialize() {
    }On the other hand, the default values and other metadata are also used to create GUIs and XML I/O for the derived operator class, without having it instantiated. So we cannot use the initial instance field values for that, because we don't have an instance.

  • How can i use class reference from an array effeciently?

    Hi,
    I made some test here with getting a class reference from an array and using the reference's methods or variables.
    Basically arrayEx is a container of type Array and it contains the Person's class instance in it. Num is a number extracted from the Person's instance
    Example #1----Strongly typed
    Var reference:Person;
    Var num:int;
    //Assignation
    reference=arrayEx[0];-----IT IS SLOW HERE
    //Use
    num=reference.number --- IT IS FAST HERE
    Example #2---Not typed
    Var reference:*;
    Var num:int;
    //Assignation
    reference=arrayEx[0]; ---- IT IS FAST HERE
    //Use
    num=reference.number ---IT IS SLOW HERE
    No matter what i change in both code like casting Person on arrayEx, i cant seem to make them work both fast at the same time
    If someone knows how, please tell me,
    Dominik

    Hi,
    I made some test here with getting a class reference from an array and using the reference's methods or variables.
    Basically arrayEx is a container of type Array and it contains the Person's class instance in it. Num is a number extracted from the Person's instance
    Example #1----Strongly typed
    Var reference:Person;
    Var num:int;
    //Assignation
    reference=arrayEx[0];-----IT IS SLOW HERE
    //Use
    num=reference.number --- IT IS FAST HERE
    Example #2---Not typed
    Var reference:*;
    Var num:int;
    //Assignation
    reference=arrayEx[0]; ---- IT IS FAST HERE
    //Use
    num=reference.number ---IT IS SLOW HERE
    No matter what i change in both code like casting Person on arrayEx, i cant seem to make them work both fast at the same time
    If someone knows how, please tell me,
    Dominik

  • Importing Inter-package classes

    hello
    I have never had this problem before but I just 'downgraded' to JDK 1.1.8 because the code will be used on my PDA. I am trying to import Inter-package classes but the compiler it cannot find the classes I've imported. This code was working perfectly in j2sdk1.4.2_02
    I think the code is right all files saved in folder graphs and beginning looks like this:
    package graphs;
    import graphs.AxisParameter;

    Yes they are in the same folder with 'package graphs;' in the 1st line,
    i've tried with and without package.class to no avail
    the exact errors i'm getting are
    without the package in front
    error: File .\CustomLabel.class does not contain type CustomLabel as expected, but type graphs.CustomLabel. Please remove the file or make sure it appears in the correct subdirectory of the class path
    with the graphs.CustomLabel i get the following errors
    error: Invalid class File formate: .\graphs\CustomLabel.class, wrong version: 46, expected 45
    2nd error: Class graphs.CustomLabel not found in import.

  • //package classes;

    i have used the code below,,and my application is working fine...but when i removed the comments from the package ling..the 404 error is coming..i have compiled the servlet with package line uncommented..whats the reason?
    //package classes;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    import java.sql.*;
    public class CookieLoginServlet extends HttpServlet {
         public void doGet(HttpServletRequest request ,HttpServletResponse response)
         throws ServletException,IOException {
              sendLoginForm(response,false);
              System.out.println("inside get");
         public void doPost(HttpServletRequest request,HttpServletResponse response)
         throws ServletException ,IOException {
              String userName=request.getParameter("userName");
              String password=request.getParameter("password");
              if(login(userName,password)){
    Cookie c1=new Cookie("userName",userName);
    Cookie c2=new Cookie("password",password);
    response.addCookie(c1);
    response.addCookie(c2);
    response.setContentType("text/html");
    PrintWriter out =response.getWriter();
    // response.sendRedirect does not work here.
    // use a Meta tag to redirect to ContentServlet
    out.println("<META HTTP-EQUIV=Refresh CONTENT=0;URL=ContentServlet>");
              }else{
                   sendLoginForm(response,true);
         private void sendLoginForm(HttpServletResponse response,boolean withErrorMessage)
         throws ServletException ,IOException {
              response.setContentType("text/html");
              PrintWriter out=response.getWriter();
              out.println("<html>");
              out.println("<head>");
              out.println("<title>Login</title>");
              out.println("<body>");
              out.println("<center>");
              if(withErrorMessage){
                   out.println("login failed .plz try again<br>");
                   out.println("if u think you have entered the correct user name "+
                        "and password,the cookie setting in your browser might be off " +
                        "<br>Click<a href=InfoPage.html>here</a> for information ");
              out.println("<br>");
              out.println("<br><h2>please enter your username and password</h2>");
              out.println("<br>");
              out.println("<br><form method=POST>");
              out.println("<table>");
              out.println("<tr>");
              out.println("<td>userName:</td>");
              out.println("<td><input type=text name=userName></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td>password:</td>");
              out.println("<td><input type=password name=password></td>");
              out.println("</tr>");
              out.println("<tr>");
              out.println("<td><input type=submit value=submit></td>");
              out.println("</table>");
              out.println("</form>");
              out.println("</center");
              out.println("</body>");
              out.println("</html>");
         public static boolean login(String userName,String password){
              try{
                   Class.forName("sun.jdbdc.odbc.JdbcOdbcDriver");
                   Connection con =DriverManager.getConnection("jdbc:odbc:JavaWeb");
                   Statement s=con.createStatement();
                   String sql="SELECT UserName FROM users" +
                   "WHERE UserName='"+fixSqlFieldValue(userName)+ "'"+
                   "AND password='"+fixSqlFieldValue(password)+"'";
                   ResultSet rs= s.executeQuery(sql);
                   if(rs.next()){
                        rs.close();
                   s.close();
                   return true;
                   }else
                   {     rs.close();
                   s.close();
                   con.close();
              }catch(ClassNotFoundException e){
                   System.out.println(e.toString());
         catch (SQLException e) {
         System.out.println(e.toString());
         catch (Exception e) {
         System.out.println(e.toString());
         return false;
         public static String encodeHtmlTag(String tag){
              if(tag==null)
              return null;
              int length=tag.length();
              StringBuffer encodeTag=new StringBuffer(2*length);
              for(int i=0; i<length; i++) {
              char c=tag.charAt(i);
              if(c=='<')
              encodeTag.append("<");
              else if(c=='>')
              encodeTag.append(">");
              else if(c=='&')
              encodeTag.append("&");
              else if(c=='"')
              encodeTag.append(""");
              else if(c==' ')
              encodeTag.append(" ");
              else
              encodeTag.append(c);
              return encodeTag.toString();
         public static String fixSqlFieldValue(String value) {
              if (value==null)
              return null;
              int length = value.length();
              StringBuffer fixedValue = new StringBuffer((int) (length* 1.1));
              for(int i=0; i<length; i++) {
              char c = value.charAt(i);
              if(c=='\'')
              fixedValue.append("''");
              else
              fixedValue.append(c);
              return fixedValue.toString();
    }

    It means you didn't deploy the servlet properly.
    Put the package back - all your Java classes should go into packages. All the time. The only exception is when you're writing a quick knock-off to test something that you'll run on the command line and rarely use again.
    No surprise - the code you've written is certainly terrible. HTML to the output stream - ever heard of JSP?
    SQL code in a servlet - ever hear of Data Access Objects?
    Layering apps makes them easier to test, debug, maintain, and understand.
    What servlet/JSP engine are you using? Tomcat? If so, Tomcat requires that you use packages.
    Where did you put this beauty of a servlet? Better not be /ROOT. Create a directory under /webapps for your app and deploy it there.
    What URL did you use to invoke the servlet? I'll bet that's wrong, too.
    Lots to correct here.
    %

  • Class loading and reflection

    Hi,
    I am trying to use a custom class loader to dynamically load Java classes so that I can get some info (e.g. methods) about the classes via reflection. My problem is that my class loader is written to load Java core classes (i.e. java.lang, java.util, etc.), which as far as I know cannot be done since ClassLoader.defineClass() disallows such attempts. The reason I need to load the core classes is because my program extensively uses Java 5 features (thus have to run using JRE version 5) but need access to Java 1.4 classes in order to get the class' info via reflection.
    I am almost out of ideas and thought that what I am trying to do might be achievable if there is a way where I can use the reflection APIs without loading a class first -- I doubt that this can be done using standard Java API, but I will appreciate it if anyone knows any tools/libraries that can do this or if anyone can give other suggestions to solve my problem.
    Thanks,
    Hendrik

    slackiz wrote:
    Hi,
    I am trying to use a custom class loader to dynamically load Java classes so that I can get some info (e.g. methods) about the classes via reflection. My problem is that my class loader is written to load Java core classes (i.e. java.lang, java.util, etc.), which as far as I know cannot be done since ClassLoader.defineClass() disallows such attempts. The reason I need to load the core classes is because my program extensively uses Java 5 features (thus have to run using JRE version 5) but need access to Java 1.4 classes in order to get the class' info via reflection.
    Just to be clear in case someone else in the future finds this....
    You cannot and must not attempt to "load" core classes from different VM versions into the same VM.
    It doesn't matter what the reason is it is will always be wrong.
    Conversely I am guessing the OP just wants to look/interpret the classes versus actually loading them. So BCEL should work or one could always roll their own class file reader.

  • ABAP Class reference in persistent container

    Hi all,
    Has anyone ever tried to read an abap class reference from a rule container in the rule's function module?
    This doesn't seem to work, unless I am doing something wrong...
    Here is the scenario:
    I have an abap class ZCL_CLASS instantiated in my workflow container. In one of my workflow steps I pass that class object reference to a rule (Function Module based). In the rule function module I use macro swc_get_element to try to get the class object reference. And there it is not getting anything.
    I have already tried the following:
    - Try to run macro swc_container_to_runtime on the rule container before retrieving the object reference -> doesn't work. The internal table ac_container doesn't even look different before and after having run this macro.
    - Try to replace the declaration of include <CNTN01> by <CNTN02> + <CNTN03>. Doesn't change anything either.
    When I look at ac_container in debugging it seems my object reference is there but looks a bit strange:
    ELEMENT | TAB_INDEX | ELEMLENGTH | TYPE | VALUE
    WFIBF_PORTAB | 000011 | 004 | u | SWFTSTRUCT
    WFIBF_PORTAB | 000012 | 032 | C | STEP
    WFIBF_PORTAB | 000014 | 032 | C | 1CCC1000C
    WFIBF_PORTAB | 000015 | 104 | C | <object key>    <class>    CL
    Any idea of how I should proceed to retrieve my object reference?
    For the moment the workaround I found is to pass the object key to the rule and to reinstantiate the class in the rule function module. Not a very elegant solution...
    Thanks in advance and kind regards,
    Patrick

    Hi Mike,
    I understand what you're saying. But the problem is that the swc_get_element macro does not even get me the LPOR value, and therefore I can't call the FIND_BY_LPOR method.
    That means I have two solutions:
    - Passing the LPOR instead of the object reference to the rule container => Not a very nice solution, for many different reasons.
    - Find an alternative to swc_get_element to get the LPOR value.
    I had a look at class cl_swf_cnt_container, and it seems it can do the trick for me.
    So what I will finally do is:
    1. Convert the BOR container into an instance of cl_swf_cnt_container.
      DATA: lo_cnt    TYPE REF TO if_swf_cnt_container,
                 lt_container TYPE swconttab.
      lt_container[] = ac_container[].
      TRY.
          CALL METHOD cl_swf_cnt_container=>if_swf_cnt_conversion~create_from_bor_container
            EXPORTING
              values                = lt_container
            RECEIVING
              container           = lo_cnt.
        CATCH cx_swf_utl_obj_create_failed.
      ENDTRY.
    2. Get my container element.
    DATA: lo_myobj TYPE REF TO zcl_class.
    CALL METHOD lo_cnt->if_swf_ifs_parameter_container~get
      EXPORTING
        name       = 'MyContainerElement'
      IMPORTING
        value      = lo_myobj
    I didn't take the time to debug that deep in the standard SAP code, but I assume the if_swf_ifs_parameter_container~get re-instantiates my class for me.
    Please feel free to comment.
    Kind regards,
    Patrick

  • Compiling java package class referring a default package class.

    I am trying to compile a java class having a package defination referring a java class with a default package.
    The code for the default package class is .
    public class Test{.
    public static void main(String[] args){
    System.out.println("Hello World!");
    This class compiles fine.
    I have another class called PackJava, whose code is :
    package test;
    import Test;
    public class PackJava{
    public static void main(String[] args){
    Test test = new Test();
    System.out.println("Hello World!");
    I have Test file in the windows path
    D:\development\packagetest\example
    and the PackJava java file in the path
    D:\development\packagetest\example\test
    I have set the CLASSPATH environment varibale as
    D:\development\packagetest\example;.
    When I try to compile the PackJava from the
    D:\development\packagetest\example path giving the command as
    javac -classpath . test\PackJava.java
    or
    javac -classpath %CLASSPATH% test\PackJava.java
    it gives me error,
    Do any of you have an idea of the parameter i should pass
    to the -classpath option
    Thanks

    There is a way around all this. The classes in the default packages need to implement an interface with the methods require. The interface can be in any package you want ie. com.work.around.interf.MyInterface1. Next, make this interface available in a Singleton. - The only catch here is that, the main method must reside in default package as well. And o, on start of main, instantiate the class you want and put it in the singleton. There after, you may refer to it from the singleton.
    Enjoy.

  • [svn] 3403: Fix for SDK-17097 - Missing summary description of a class in package classes table

    Revision: 3403
    Author: [email protected]
    Date: 2008-09-29 12:36:37 -0700 (Mon, 29 Sep 2008)
    Log Message:
    Fix for SDK-17097 - Missing summary description of a class in package classes table
    QA: Yes
    Doc:
    Tests: checkintests
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17097
    Modified Paths:
    flex/sdk/trunk/asdoc/templates/class-files.xslt

    Well, it's kind of logical that as you put more jar files (classes) in Tomcat, it changes the error to ask for the classes (inside a jar) it cannot find.
    There was a good class->jar finder on the internet some years ago, but i don't remember the address. Try looking for that and search all the missing classes (NotDefined) and their correspondig jar files.
    Good Luck!

Maybe you are looking for