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 :)

Similar Messages

  • TEXT_IO.FOPEN how to pick file without specifying the full directory path

    Hi,
    I am using Oracle application server 10gR2 on Linux with forms 10g application. I am building the DEV/TEST/UAT environment on same Linux machine with one OAS.
    I am using TEXT_IO.FOPEN ('/home/oracle/check.txt','r') to read a server side file and it is working fine.
    Now I want to pick this file dynamically i.e. without specifying the full path. I am using TEXT_IO.FOPEN ('check.txt','r') and I copied file in forms_path directory in linux and even in $path directory in linux but none of them are working.
    Pls help me sort out this problem.
    Thanks in advance

    Hi,
    I have to read files in my app directory using TEXT_IO how is that possible?? I cannot set workingDirectory as my Oracle home is in a different location and as has been mentioned by others when I run the form on web it cannot seem to find the file in the default forms directory where all the .fmx file
    Is there any other file setting that needs to be done??
    Please help
    Thanks & Regards
    Mangesh Deshpande

  • But how do I create a new iTunes backup password without knowing the previous one?

    In case anyone keeps track of such things, I'm among those folks who really doesn't recall ever being asked to create an iTunes backup password, but that's irrelevant to my question.
    I'm not in any bind. I don't need my backup files to restore anything. I will shed no tears as they are moved to the Recycle Bin (indeed, I will gladly do the deed myself).
    That said, it appears impossible to create a new backup password without knowing the previous one.
    If the only "solution" is to wipe my iPhone's memory and start from scratch, I will be a sad camper.
    Any help? Are backups to iCloud encrypted?
    Cheers...

    Additionally:
    Be super critical & meticulous (and whatever other synonym I missed) when you get a new password:
    Write it onto your bedroom wall, or someplace off of a computer that you will always find.
    If you active 2-step verification, the key is VERY important. Lose it & you may be toast.
    If you don’t 2 step verify, & use the Security Question instead --> do not lose, or forget the answers.
    Very nearly the same outcome!!!!!:  Bad experience.
    If you add a 2nd email address, make sure its a RESCUE address not just an alternate address.
    If you lose these, you lose access to your 3rd party purchases via Appstore for future upgrade. That will make you VEWY, VEWY UNHAPPY. Apple new OS versions do update, but add a new device & likely you will be unable to use your content on that device. It will never load if the ID locks up.

  • HT4113 how to unlock an ipod touch without knowing the password

    how to unlock an ipod touch without knowing the password

    Connect the iPod to your computer and restore via iTunes. Place the iPod in Recovery mode if necessary to allow the restore.

  • How do you reset an ipad mini without knowing the password?

    I have just recently changed my password, but know i have forgot the new one. How do you reset the ipad without knowing the password?

    If you mean the passcode to unlock the iPad then you will need to connect it to the computer that you normally sync to and you should then be able to reset the iPad and restore/re-sync your content to it (http://support.apple.com/kb/HT1212) - you may need to put the iPad into recovery mode in order to be able to reset it : http://support.apple.com/kb/ht1808
    If you do it via a different computer then :
    If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present.

  • How do you unlock an ipod touch without knowing the password

    How do you unlock a ipod touch 4th generation without knowing the password?

    Connect the iOS device to your computer and restore via iTunes. Place the iOS device in Recovery Mode if necessary to allow the restore.
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • Pickup a class in application without bouncing the WLS

    Hi,
    I've an application(deployed on WLS) which basically takes the name of a class and delegates it to another process, which then loads the class and calls a few methods reflectively. For this, I want the second process to reference to a directory(outside the ear) so that it looks for the resolution in this directory.
    Now, the problem is, how to make the application refer to this directory. I do not want them to be loaded by server classloader as they will unnecessary be available to all other applications. So, adding the name to server classpath or deploying it as shared library is ruled out.
    Other requirement is, the jar file can be introduced dynamically by a user into the directory and the application should take care of it for any references. Bouncing application should do this needful.
    Does WLS have a feature to cater to this need?
    Thanks.
    Nitin

    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

  • I forgot my password for my apple ID. Any ideas on how to put in a new one without knowing the old one?

    I forgot my password for my Apple ID. Anyone have a solution on how to put in a new one without knowing the old one?
    Thanks

    Welcome to Apple Support Communities
    You have to reset your password. You can do this in this site > http://iforgot.apple.com

  • Is it possible to delete extended properties without knowing the id?

    Hello,
    Can you delete any custom extended properties without knowing their ID?
    I took over managing a feature that used EWS to send emails to customers.The current code creates a new GUID, and thus new Extended Property, every time an email is sent.
    // Create a custom extended property and add it to the message.
    var myExtendedPropertyDefinition = new ExtendedPropertyDefinition(Guid.NewGuid(), "MyGuidId", MapiPropertyType.String);
    mail.SetExtendedProperty(myExtendedPropertyDefinition, "MyGuidId");
    // Send and save a copy
    mail.SendAndSaveCopy();
    Is there a way to delete any of the custom extended propeties without knowing the IDs?
    Thank you

    No you can't do that in EWS you need to know the details of the property you want to Read/Write or delete. EWS has no method of enumerating all extended properties either you would need to use MAPI to do this.
    >>The current code creates a new GUID, and thus new Extended Property, every time an email is sent.
     I'd question the design of this what where they trying to acheive ? Why not have ths same property with a different Value ? else using an X-header would be better idea at least then it will persist ouside of your Exchange infrastructure and even
    inside would be more discoverable.
    Cheers
    Glen

  • 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.

  • How can I reset my administrator password, without knowing the original administrator password?

    Hi guys,
    I use a MacBook Pro with OS X 10.8 Mountain Lion. A few months ago I reset my administrator password and have not been able to remember it since. Consequently, I haven’t been able to do any software updates, my computer is running slow and I'm getting a lot of pop-up junk on my screen. I’m the only user on my computer, apart from the Guest User (Sharing only).
    How can I reset my administrator password, without knowing the original password?
    Thanks.

    Resetting Password and/or Home Folder Permissions

  • How do i reset an admin password without knowing the original?

    How can i reset my admin password on my macbook pro without knowing the original password?

    Insert a compatible Mac OS X DVD, restart with the Option key held down, and use its Reset Password utility. If the computer has a firmware password set, you need to know that.
    (58431)

  • How do I get new episodes to load on seasons I bought without buying the new episodes, how do I get new episodes to load on seasons I bought without buying the new episodes

    how do I get new episodes to load on seasons I bought without buying the new episodes?

    I do believe it's automatic if you load iTunes.

  • HT4865 How to delete the preowner icloud account without knowing the password?

    How to delete icloud account from pre owner without knowing the password?

    II'm in the same situation. Purchased a refurbished IPhone 5. I had to do a factory reset and when I reset it again, itunes tells me that the phone is linked to someone else. Called the company I bought the phone from and they say iTunes can do a master reset to link my iTunes account to the phone. Have any of you heard of this being possible?

Maybe you are looking for

  • AIM on Treo Pro??

    How do I get AOL Instant Messanger (AIM) on the TREO PRO??? Post relates to: Treo Pro T850U (Unlocked) This question was solved. View Solution.

  • Maxtor One Touch II Won't Mount

    I'm running 10.6.8 and my maxtor one touch II won't mount all of a sudden? I've tried fire wire 400 and fire 400to800, restarting etc. The drive won't show up? The driver update on the Maxtor/Seagate site opens up as code in a text edit file, it does

  • Movie and audio not synchronized in the swf file.

    Hello, I have a main movie that call and display movies from the library. In each of those library's movies i have an animation on a layer and a sound (about 15 secondes) on another layer which i want synchronize. When i check each movie on my .fla d

  • Customer Master giving "Data is incomplete; check ;Message F2125" on saving

    While creating Customer master for a newly defined sales organisation, when i try to save the entry, the screen goes to Partner Function and it displays the error :- Data is incomplete; check Message no. F2125 What needs to be done Thanks amit

  • Test whether doc is opened in Reader or browser plugin

    Hi, is there a way to test programmatically whether the current document is opened in the full Reader application or in the web-browser plugin? Alexander