How to resolve class reference in java?please join in!!

Hello all!
In delphi ,there is a statment of reference of class,like "class of TSomeClass,I have some code write in delphi expediently,but in java hardly,please give some suggestion.here are my codes in obj.pas writed in delphi:
TObjClass = class of TObj;
TObj = class(TObject); //TObj is a base class..
class procedure TObj.basemethod(..)
begin
end;
TApp=class(TObj);//TApp inherted from TObj;
class procedure TApp.basemethod(...)//override the method in TObj
begin
end;
TProp=class(TObj);//TProp inherted from TObj too..;
class procedure TProp.basemethod(...) //override the method in TObj
begin
end;
TObjlist=class(TObjectlist); //anther third class
private Itemclass:TObjclass;
constructor TObjlist.Create(AClass : TObjclass);
begin
Itemclass:=AClass;
end;
public TObjlist.somemethod();
begin
Itemclass.create; //hardly writed in java;
itemclass.basemethod(); ////hardly writed in java to invoke class method;
end;

You need to study the javadocs for java.lang.Class and for java.reflect.*;
Each class in a program has an associated Class object which you can get from the classname as MyClass.class or from an object as myObject.getClass()
From the class object you can create a new instance, or you can get a Method or Constructor object from the class and invoke that.

Similar Messages

  • I need a mechanism to expose action script class reference to java script

    I need a mechanism to expose action script class reference to java script

    Adobe, I think, are quite happy leaving the StageWebView as a highly efficient and low-level component accessing native functionality, so I wouldn't hold my breath on them extending it.
    That said, I believe somebody did implement an ANE that gives much more access and, according to the docs, does allow Javascript access.
    See UIWebView as per this thread; http://forums.adobe.com/message/4832821#4832821
    http://darkredz.com/ios-uiwebview-and-videoplayer-native-extension-for-air-mobile/
    G

  • How to convert .class files to .java files

    Hi,
    I want to convert .class files to .java files. Is there is any software for that doing except Dj DCompiler? Because if i am using this i am not getting proper code i mean as it is available in the file.
    I tried by writing simple java file and i compiled Sample.java file and i got a .class file then i converted this Sample.class to Sample.java file by using DjDcompiler but i was missing some statements i need entire code that is available in Sample.java file. Please tell me any other software for that doing.
    Thank you in advance

    I want to convert .class files to .java files.
    iles. Is there is any software for that doing except
    Dj DCompiler? Because if i am using this i am nothttp://www.google.com/search?hl=en&q=java+decompiler&meta=
    getting proper code i mean as it is available in the
    file.I doubt you ever will.
    I tried by writing simple java file and i compiled
    Sample.java file and i got a .class file then i
    converted this Sample.class to Sample.java file by
    using DjDcompiler but i was missing some statements i
    need entire code that is available in Sample.java
    file. Please tell me any other software for that
    doing.Did you hear about "compiler opimizations"?

  • How to convert class files into java files??

    Hey Guys,
    I need a little help.
    I want to know wheather we can view .class files as .java files or convert the .class to .java files.Is ther any tool or software for doing that.
    Or in other words can i see the source code of any .class file..??
    Plz do tell me if we can do that or any other way we can do that.
    Regds,
    Gokul

    Sort of. A "decompiler" will take a class file and generate a source code file of source code that could be compiled to get the class file you started out with. However, it won't be the same source code that was originally used to create the class. Most notably, comments will be missing, and variable names will probably be meaningless.
    And before you say "java is bad because you can decompile it", note that any language that you can execute you can theoretically decompile.
    Also, you can view the raw byte codes. If you're familiar with assembly language, or better yet familar with java bytecodes and the JVM in particular, you can often find out what a particular method does just by viewing the byte codes.

  • How to reload class file for java objects in CF MX7

    I'm trying to create a simple java object for use in a CFML
    page. According to the topic "About ColdFusion and Java objects" in
    the CF developer's guide, I can compile my java module and put the
    .class file in the CFusionMX7/wwwroot/WEB-INF/classes directory and
    it'll be dynamically reloaded any time CF sees a new .class file
    there. But the dynamic reload isn't happening; I have to restart
    the CF server to get it to pick up a new version.
    I don't believe this directory is in the "general JVM
    classpath"; I don't find "classes" in the Java Class Path in the CF
    Administrator's System Information page. And I have all the caching
    options turned off on the "Server Settings > Caching" page, if
    that has any bearing on it.
    Are there any known issues around this dynamic reload
    capability, or maybe a more definitive way to make sure the
    WEB-INF/classes directory isn't in the classpath?
    Thanks,
    James

    Yes, I understand. But if I'm reading it correctly, what
    you're saying seems to contradict the documentation
    http://livedocs.adobe.com/coldfusion/7/htmldocs/00001561.htm
    ColdFusion dynamically loads classes that are either .class
    files in the web_root/WEB-INF/classes directory or in JAR files in
    the web_root/WEB-INF/lib directory. ColdFusion checks the time
    stamp on the file when it creates an object that is defined in
    either directory, even when the class is already in memory. If the
    file that contains the class is newer than the class in memory,
    ColdFusion loads the class from that directory.
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_18228&sliceId=1
    Dynamic class reloading for Java servlets classes and
    forcfobject (sic) Java classes is disabled by default in
    ColdFusion MX. To enable dynamic class reloading, do the following:
    Also, I seem to recall that setting worked in a prior
    version. Though I would have to test it again on another machine to
    be certain.

  • How to convert class file to Java source code ?

    Hi All ,
    Currently am working in Peoplesoft Demo project using java as Plug in.We have only the class files and jar files and we have planned to modify the code for future enhancements.We dont have any legal issues here as we are already working with our client for the original source code.
    Kindly help me out in doing this reverse engineering process.We have come to know the below steps would help us out.Can someone guide us in acheiving this process step by step.Please add your experience here and let us know what are the other steps required ..
    (1)Rename the file from .jar to .zip and extract the .zip file.
    (2)Decompile the desired .class file using 3rd party tool and get .java file.
    (3)Modify the .java file and compile it.
    (4)Now zip the extracted files and rename the it from .zip to .jar.
    We need to verify whether the modified .jar file will work
    Thanks & Regards
    Kar1983

    Thanks for your reply ....We have asked them so many times ..but they say they dont have it .Since we have planned to do some enhancements from our end we have planned to do reverse engineering process.

  • How to find classes in a java package

    i am writing a java IDE. i want to extract all class names from a java package eg. java.lang (through coding). how can i do that.
    Thanks in advance

    File file = new File("path to your jar file");
    JarFile jf = new JarFile(file);
    Enumeration e = jf.entries();
    ZipEntry ze = null;
    while(e.hasMoreElements()){
    ze = (ZipEntry) e.nextElement();
    ze.toString(); // gives you the file name
    you have to understand java.util.jar java.util.zip packages for working with jar/zip files.
    Hope this helps

  • How to decode .class files to .java files?

    I just want to know that how can I decode .class files back to .java files?
    If anybody can tell, it will be of great help.

    On a related note, how can I make it such that this cannot be done?
    I understand the format is not private so it's not impossible for someone to go backwards.
    I'm also aware of some programs that alter your source to make it more difficult for people to understand after decompiling it.
    Regards,
    Nick G.

  • Resolve self-reference table by alias tables in detail

    Hello Gurus,
            can you tell me how to resolve self-reference table by alias tables in detail?
    Many thanks.

    Hello, for the following step 3, I don't understand, will you please give me some explanation for step 3?
    Save your Staff universe, and test the results in Web Intelligence Rich Client as follows:
    1. Run a query using Manager and Employee. Add a count on both columns.
    2. Add a query with only the Manager object. Add a count. Is this the correct value?
    3. Open your Staff universe in Universe Designer and edit the Manager object. To ensure
    that the data is restricted to only manager data, use the Tables button. Select the
    EMPLOYEE table, to force the object to use the join between the table and restrict the
    data.
    4. Test the result, creating a new query with only the Manager object. It returns the correct
    number of managers.
    5. Edit the query and add Employee. Run and display the count. There are 26 rows. Why?
    The join restricts the data to look only for employees that have managers. However, there
    is a manager that does not have a manager, and is now excluded.
    6. Open your Staff universe in Universe Designer and add an outer join on the MANAGER
    table side.
    7. Save the changes and test the results in Web Intelligence Rich Client.

  • Class file to java file conversion

    is it possible to convert .class file into .java file & if yes
    then how to convert .class file into .java file.
    plz. mail me ans. on [email protected] | [email protected]

    Yes there are many Java Decompilers which converts the Java bytecode class files to Source files, You may find the follwing URLs helpful:
    http://www.brouhaha.com/~eric/computers/mocha.html
    http://members.fortunecity.com/neshkov/dj.html

  • How to make class hiearchy,chractorstic hiearchy

    hi
    all
    how to make class hiearchy,chractorstic hiearchy
    please tail me the purpose with trs code
    suitable answers will be rewarded

    manoj,
    See [here|http://help.sap.com/erp2005_ehp_03/helpdata/EN/24/4765e5416711d189ec0000e81ddfac/frameset.htm] for more info
    PeteA

  • How to resolve error - 502 web server error ?

    Hello,
    Kindly consider following scenario: 
    Custom control is programmatically creating site using following code. Once site get created, it redirecting to its settings.aspx page:
    try
    SPSecurity.RunWithElevatedPrivileges(delegate()
    using (SPSite
    site1 = new
    SPSite(SPContext.Current.Site.ID))
    SPLongOperation.BeginOperation
    beginOperation = null;
    if (beginOperation ==
    null)
                             beginOperation =
    delegate(SPLongOperation
    longOperation)
                                 site1.WebApplication.Sites.Add(site1.RootWeb.Url 
                      + "/manPath/site1,
    Site1, "", 1033,TemplateName,
    __userLoginName, __userName,__userEmail);
                                 longOperation.End(site1.RootWeb.Url
    + "/manPath/site1/_layouts/settings.aspx");
    SPLongOperation.Begin(beginOperation);
    Same code works perfect at development machine, while in production it gives 502 web server errors.
    Please check below error text:
    502 - Web server received an invalid response while acting as a gateway or proxy server.
    There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content server, it received an invalid response from the content server.
    Results in Development machine: site gets created and redirects to its site settings page as expected.
    Results in Production machine: During the process it throws 502 web server errors, while site has got created successfully.
    I am not sure why it happened, while previously it was working. I have feeling that may be redeployment should resolve the issue, but I want to know root cause of this issue!!
    Note :  the same settings page is working well, when I open it manually in production environment!
    Please let me know the approaches to resolve this issue? Also, let me know if you need any further information on same.
    Thank you to look at this issue !
    Kind Regards,
    Dipti Chhatrapati

    Hi, I have found the things where is the issue , but still I am looking for the resolution !
    To add further on above issue, I have observed as below :
    Client machine: Following
    error is getting throw when creating new  site. 
    502 - Web server received an invalid response while acting as a gateway or proxy server. 
    There is a problem with the page you are looking for, and it cannot be displayed. When the Web server (while acting as a gateway or proxy) contacted the upstream content
    server, it received an invalid response from the content server. 
    WFEs
    machine : Error is not getting display when creating new site.
    And hence , it looks like load balancing/IIS issue, however I am not sure how to resolve the same !! 
    Please let me know your thoughts !
    Thanks and Kind Regards,
    Dipti Chhatrapati

  • How to save a reference to a class depending on a conditional statement...

    Hi!
    I'm rather new to Java, but I'm already in the process of creating a rather big application (big, from my point of view) :).
    I have a main class, in which I find out what OS the application is running on (utilizing System.getProperty("os.name")). If the string corresponds to Windows (I'm using regular expressions to match this), I create an instance of another class called WindowsPlatform.java. And vice versa for Unix.
    My problem is that I'm not really sure how to save a reference to the Unix or Windows platform class, as the program conditionally decides, depending on the platform, which class to invoke.
    The error Java's giving me is:
    MainClass.java:9 cannot find symbol
    symbol  : method sayHi()
    location: class Platform
            platform.sayHi();
                    ^
    1 errorWhat I want is to have the sayHi() method invoked from whatever class (UnixPlatform or WindowsPlatform) that was earlier in the program used as argument for the setPlatform() method in Initializer.java.
    This is the the code involved (class names have been changed to easier reflect their purpose):
    ### MainClass.java ###
    public class MainClass
        public static void main(String[] args) {
            SettingsClass settings = new SettingsClass();
         Initializer init = new Initializer(settings);
         Platform platform = settings.getPlatform();
         platform.sayHi();
    ### SettingsClass.java ###
    public class SettingsClass
        private Platform platform;
        public void setPlatform(Platform _platform) {
            platform = _platform;
        public Platform getPlatform() {
            return platform;
    ### Initializer.java ###
    public class Initializer
        private SettingsClass settings;
        private RegExpr re;
        private String os;
        public Initializer(SettingsClass _settings) {
            settings = _settings;
            re = new RegExpr();
         os = System.getProperty("os.name");
         if (re.find(".*win.*", os, true)) {
                settings.setPlatform(new WindowsPlatform());
         } else {
                settings.setPlatform(new UnixPlatform());
    ### Platform.java ###
    public class Platform
        /* Some generic functions applicable to
         * all platforms
    ### RegExpr.java ###
    import java.util.regex.*;
    public class RegExpr
        private String regExpr;
        private String str;
        private boolean iCase;
        public boolean find(String _regExpr, String _str, boolean _iCase) {
            this.regExpr = _regExpr;
            this.str = _str;
         this.iCase = _iCase;
            Pattern pat;
         Matcher matcher;
         if (iCase) {
                pat = Pattern.compile(regExpr, Pattern.CASE_INSENSITIVE);
         } else {
                pat = Pattern.compile(regExpr);
         matcher = pat.matcher(str);
         if (matcher.find()) {
             return true;
         } else {
                return false;
    ### UnixPlatform.java ###
    public class UnixPlatform extends Platform
        public void sayHi() {
         System.out.println("Hi, I'm Unix!");
    ### WindowsPlatform.java ###
    public class WindowsPlatform extends Platform
        public void sayHi() {
         System.out.println("Hi, I'm Windows!");
    }I would greatly appreciate any help I could get on this issue!
    Thanks for your time!
    Regards, ridgero

    Dear Ridgero, your method must exist in your Platform class. Now you can only call this method from UnixPlatform or WindowsPlatform. The two easiest ways to resolv this would be something like:
    abstract class Platform
        /* Some generic functions applicable to
         * all platforms
        abstract void sayHi();
    }or this:
    public class Platform
        /* Some generic functions applicable to
         * all platforms
        abstract void sayHi() {}
    }Good luck.

  • How to resolve preverifying class exception while building

    Hi,
    I am new to J2ME, i am getting preverifying class exception when ever building a application using Wireless Toolkit 2.1, JDK1.5, CLDC 1.1.
    actually i need to run web application on mobiles (PDA), can any one suggests how to resolve the above exception and what are the jar files required in classpath.
    Please let me know.
    Thanks
    ST_Reddy.

    Then leave it as it is. If the method doesn't throw the exception it is not a problem.
    If you need to throw the exception in some rare cases, then throw RuntimeException. It is not required to declare such exception in interface.

  • 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

Maybe you are looking for