Load Jar and access a class in jar at run time

I need help from you.
How to load a Jar and access a class in the jar at run time?
When i try the following code it works fine while running in Java (Jdk1.5).If iam running the same code in servlet,ClassCastException occurs.
Error Message : ClassCastExcption : jartest1 cannot be cast to Thing
test.jar contains jartest.class and Thing.class
jartest1.java
try{
File file =new File("test.jar");
String lcStr ="jartest";
URL jfile = new URL("jar", "", "file:" + file.getAbsolutePath() +"!/");
URLClassLoader cl = URLClassLoader.newInstance(new URL[] { jfile });
Class loadedClass = cl.loadClass(lcStr);
Thing t=(Thing)loadedClass.newInstance();
t.execute();
catch(Exception e)
System.err.println(e);
Thing.java
public interface Thing
void execute();
jartest.java
public class jartest implements Thing
public void exceute()
System.out.println("Welcome");
Thanks and Regards
V.Senthil Kumar
Edited by: senthilv_sun on Dec 16, 2008 8:30 PM

senthilv_sun wrote:
I need help from you.
How to load a Jar and access a class in the jar at run time?
When i try the following code it works fine while running in Java (Jdk1.5).If iam running the same code in servlet,ClassCastException occurs.
Error Message : ClassCastExcption : jartest1 cannot be cast to ThingPresumably we can only hope that that is a transciption error. It always helps to use copy and past actual errors and code rather than manually typing them.
test.jar contains jartest.class and Thing.classWrong.
The interface class and plugable class must not be in the same jar.
A plugable interface requires two components
- Interface (generic sense)
- Functional components.
The Interface must be independant (own jar) so that it is available to the framework (user of plugin) and to the functional components. And the plugable component must not be on the java class path.
This also means that we know for certain that the plugable component is also on the system class path. That is a bad idea as well.
Given that it is pretty pointless to even speculate as to why this error is showing up. Create the correct jar layout. Test using the command line. Then test using servlets. Insure that the plugable jar is NOT on the java classpath for both tests.

Similar Messages

  • HT201250 I run time machine on my iMac using an external hard drive.  I just bought a MacBook Pro and want to know if i can run time machine on it using my wireless network on to the iMac external hard drive

    I run time machine on my iMac using an external hard drive.  I just bought a MacBook Pro and want to know if i can run time machine on it using my wireless network on to the iMac external hard drive

    How do I set up Time Machine to a shared drive on another Mac?

  • Any possibility for loading and changing XFL/... data at run time of Flash app?

    Hi everybody,
    I have a quick and general question for the following case:
    I want to produce some transitions and effects for a kinetic typography project in After Effects and then import these parts into Flash Professional via XFL and Bridge.
    So my actual problem is this one: my Flash application should be able to load these made transitions and effects dynamically at run-time and not from a pre-configured timeline made upfront. Because there should be dynamic text fields in these XFL data from After Effects I also need to be loaded at run-time for the kinetic typography thing.
    So is there any possible way to do / load / change the dynamic text fields in these XFL data or the order of all transitions and effects in Flash Professional at run-time or anything else?
    I know this is a special question, but I hope there would be an answer...
    Thanks for your help in advance
    Regards,
    Kevin

    Something along this model is what I had in mind:
    public class MainPanel extends JPanel
        private DrawPanel drawPanel = new DrawPanel();
        private JComboBox comboLeft = new JComboBox();
        private JComboBox comboRight = new JComboBox();
        public MainPanel()
            // add drawpanel and comboboxes to main panel
            // add item listener to comboboxes
        private class ComboListener implements ItemListener
            @Override
            public void itemStateChanged(ItemEvent arg0)
                if (...) // both comboboxes changed
                    // get values from comboboxes
                    drawPanel.setValues(left, right); // call drawpanel's method
    public class DrawPanel extends JPanel
        private int left = 0;
        private int right = 0;
        public DrawPanel()
            //setPreferredSize(....); // set panel size
        @Override
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            //... draw the line depending on the left and right value
        public void setValues(int left, int right)
            this.left = left;
            this.right = right;
            repaint();
    }

  • Getting LabVIEW load error code 59 using LabVIEW 2010 with a Run Time Engine.

    I use a vi compiled with a run time engine to run separate vi’s in my application directory. Once a file association is made with this exe file any Vi in my application directory is available to be loaded as needed. This is a process that has been very successful for me over the years and would prefer to continue using this process. Most of my applications are running in LabVIEW 8.6 and have moved them to 2009. First indications are in 2009 this process is still working. However, I plan to go on to 2010 before upgrading my test stations.
    In 2010 I get the error 59: “The source file’s compiled code has been separated, and this version of LabVIEW does not have access to separated compiled code.”
    The same dialog box also presents, (Hex 0x626)  “Cannot open a VI with separated compiled code in a Run Time Engine that has no access to the VIObjCache.”
    What can I do in the build that will get around this error?
    Thank you

    Thank you for the solution. I am sure this works until the next vi in the vi library gets this option selected.
     The bigger issue is I was doing something that National Instruments did not support. When I started in the days of LV 4.0 it was recommended to me that I use this method as virtually all my applications were for in house projects. This is still my preference because it gives the most versatility and allows modifications of single files rather than compiling the entire application.
    The final solution I ended up with for those who may be having the same issues. My recommendation for what it is worth, is to compile the application as an executable. This is from what I can tell the only acceptable and supported method. Using this method the problem is solved.
    I have accepted this as the solution. I still don't like it. I could list the reasons why but it is a mute point.
    Thanks again for taking the time to respond to this issue and offer the solution you found.

  • When access BW from Crystal I get: run-time error '-2147417848(80010108)'

    Installed Crystal and the SAP int Kit in the correct order. I can access R/3 but get an error when trying to access BW:
    run-time error '-2147417848(80010108)'
    Then Crystal crashes and shuts down.

    Yep, I have the same... The only one solution for me for now is open report, then log in to BW using toolbar icon from SAP integration kit bar. Only after that you can work with this report without crash.

  • LabVIEW 2009 3D Plot has no Loose Fit property and Axis AutoScale does not function at run time ?

    I cannot find a Loose Fit property for the new 3D plots (waterfall, ribbon) in LV 2009.  As a result, my data range of 1402 to 1407 ends up on a Z axis range of 1400 to 1500 and looks like a flat line.
    The Z Active Axis properties Range Maximum and Range Minimum can be used to set the range but the Z Axis Autoscale property had to be changed to False using either the front panel Plot Properties at edit time or using the Range Auto Scale property at run time on the block diagram.  It could not be changed at run time by popping up on either the plot border or on the Color Palette.
    In edit mode, R-clicking on the Color Palette's AutoScale Z did not make that property toggle or stick and did not change its function.
    At run time, there are two AutoScale Z selections shown.  One along with the X and Y scales and another by itselfat the bottom.  Again, clicking the one that is part of the X and Y axis did not make its setting stick and did not have an effect.  What does happen though is that the other AutoScale Z shown at the bottom of the Color Pallete popup does toggle its state.  But clicking on the AutoScale Z shown at the bottom does not toggle its state.
    The grey border region of the plot area contains at run time, popup setting for X,Y and Z AutoScale that likewise have no effect.
    Or am I missingsomething ?
    Message Edited by SteveP on 08-15-2009 07:55 PM
    Attachments:
    LV 2009 3D Plot Axis Autoscale.vi ‏18 KB

    Steve,
    you should be able to successfully change the scales based on the min and max values as long as you explicitly turn off autoscale. In your program, I just right-clicked the  Range Auto Scale property selected "change to write", then made a control so that I could set the value myself. Clean up the broken wires, and the program runs like it's supposed to - resetting it's scale range: 
    is this the result you wanted? 
    Misha

  • Datatypes and names of columns of recordgroup during run-time

    Hi everyone,
    Can you please tell me that Is it possible to get the datatype and name of columns of a recordgroup during run-time or not. So that I don't waste my time in searching for this solution. If you are not getting my question then please let me know but I need this help very badly.
    Thanks
    Subodh

    After  the call of the methods GET_COLUMN_WIDTH or  GET_ROW_HEIGHT
    You need to add this command :
                            CALL METHOD cl_gui_cfw=>flush.
    This will send back from the SAPGUI  to your ABAP program the new values.
    Found in this Thread  : Method GET_ROW_HEIGHT
    Eric

  • We have three different logins or accounts on our computer.  In the administrator's login, iTunes loads, syncs, and accesses the store fine.  On my two kids' logins, however, loading, syncing and acessing the store takes exponentially longer.  Any ideas?

    We have three different logins or user accounts on our comoputer.  In the administrators' login, we have no trouble opening iTunes, syncing the iPod or accessing the store.  However, in my two kids' logins, getting iTunes to recognize the device, sync it, or access the store takes exponentially longer.
    Does anyone have similiar trouble with this, and if so, do you have any suggestions?

    I think this is an excellent indicator that not only is Palm reviewing the feedback from the support forums here, but actively reviewing feedback/comments/wishes on other sites as well.
    As the original poster copied this (quite solid, IMO) wishlist from Pre Central, the palm support staff acknowledged first seeing it there.

  • Server.app can't load alerts and throws out error getAndLockContext: flock(servermgr_info) FATAL time out

    Hi everybody,
    I did a working migration of my Lion Server stating all services has been migrated successfully!
    All my used services are running fine (dns, mail, iCal, dhcp, web, VPN, adressbook, profilemanger, sharing, opendirectory) but using server.app causes an error while server.app seems to load the alerts section without success throwing out some message windows and those messages in my log console
    servermgrd[36677] [36677] error in getAndLockContext: flock(servermgr_info) FATAL time out
    servermgrd[24195] [24195] process will force-quit to avoid deadlock
    com.apple.launchd[1] (com.apple.servermgrd[24195]) Exited with exit code: 1
    Servermgrd process goes up to 100% and you have to quit server.app to calm it down.
    Anyone got a similar error or knows any workaround to abandon this error?
    Thanks and regards
    Eldrik

    RB jp's solution (move the /var/log/eventmonitor folder) solved my problem completely.
    Not only did Server.app suddenly become response again, the spinner trying to access alerts stopped spinning.
    Best of all, the servermgrd daemon stopped crashing every two minutes!  There were messages in system.log that read:
         error in getAndLockContext: flock(servermgr_info) FATAL time out
         server servermgrd[38070]: [38070] process will force-quit to avoid deadlock
    Those are now gone.  Server is happy again.

  • Wireless does not load balance and Connection drops to 1Mbps at a certain time

    Hi,
    We had wireless LAN setup and it seems that every afternoon, the connection notification on their laptop drops to 1Mbps and slowness on the network is experienced. how can I identify the cause of this drop connection speed?
    Also when one of the APs went down, the other nearby APs does not cover for the AP that went down, is it not supposed to cover for the downed AP?
    BTW out setup is LAP with 4400 series WLC with VoWLAN running on it but on differed radio and SSID. Data is on b/g while VoWLAN is on A.

    also i am seeing a lot of coverage hole detection on the logs.
    is there any problems with the coverage of the APs? should I place additional APs to cover up the holes?If you have available funds/resources then putting additional APs won't hurt ... especially if one of the APs fail.  Putting additional APs will also help distribute the clients.if it is cause by rouge AP how can i prevent it.
    First, you have to know what radios is the AP using.  For example, if the Rogue AP is using 802.11b then disable your 802.11b or use a different channel.  I'm curious to know this is the case since the WLC would've used a different channel if a Rogue AP is broadcasting on similar channel (unless there's just too many Rogue APs using 802.11b).
    you recommed any steps on how can i trace sudden  surge of wireless use I'd like to identify/isolate how correct is my hypothesis that it's due to the sudden surge of wireless use.  If this is the case, then I'd also like to know what application(s) are being used to overwhelm the wireless.

  • Can I substitute one class for another at run time

    In one compilation unit, there are 2 classes. One is public.(class Test is public and class Process is without any modifier. Test is inherited from Process). There is a private method in Process. When i try to compile while accessing the private method of Process in Test, I get a compiler error, rightfully so. But I successfully got a Process.class.
    So, now i remove the private access modifier from my method in Process class and compile the whole thing and am able to run (java Test). But, if i replace the latest Process.class with the original Process class with the private method, I am still able to run(java Test)!!
    This all happed in Windows NT but not in Solaris.
    Is this correct ? Is this not a security violation?

    It's a bug: http://developer.java.sun.com/developer/bugParade/bugs/4293149.html

  • Child class not called at run time labview

    I'm developing a large application using a few Class.
    In development mode, everything works fine.  When I build the application and run the executable, one of my child class is not called at all.  In some of the methods of that child class I have checked the option in "Window Appearance" to show the Front Panel when VI Load.  The VI show it self but is not executing.  The run button is in a state that indicate there is no top vi calling it.
    I have played whit Execution : Preallocated clone reentrant execution and General: Separate compiled code from source file.
    And I set them back to default.
    Two days lost trying to figure what append to my application.
    Please Help.
    Nitrof

    Hi Nitrof,
    Check out this excerpt straight from the NI Training Manual on object-oriented programming (image attached). There's a chance that the child classes aren't being included in the build. They need to be included somewhere in the application VI so that the Application Builder knows to include the class in the build.
    Also check out this forum that sounds like it's describing a similar problem: http://forums.ni.com/t5/LabVIEW/Problems-with-dyna​mic-class-load-in-executable/m-p/2139116
    Hope this helps!
    Alexandra
    National Instruments
    Applications Engineer
    Attachments:
    Forum1937225.png ‏146 KB

  • UPS for 2 dell r710s and some switches. What gives longest run time?

    Hello all, I hope this section also counts for battery backup? I have been looking at tons of different options for UPS, and of course there are the watts, VA ratings, and amount of batteries you actually have connected, but what is the best to shoot for?We have one eaton 9130 with an extra battery pack on it, but most everything is plugged in to it and its at nearly full load as is. We also have 2 dell R710's that I have each individually one larger individual UPS's, but they are only the bigger desktop model ones.I am trying to get a decent runtime setup to put the 2 r710's on, and probably half the switches (6 of them total, HP procurve's 1 48, 3 24's, and 1 16port L3, and a sonicwall tz215)I was looking at the cyberpower systems backups, and they have 3kw ones with extra battery options.Can anyone make a recommendation on what...
    This topic first appeared in the Spiceworks Community

    Hello all, I hope this section also counts for battery backup? I have been looking at tons of different options for UPS, and of course there are the watts, VA ratings, and amount of batteries you actually have connected, but what is the best to shoot for?We have one eaton 9130 with an extra battery pack on it, but most everything is plugged in to it and its at nearly full load as is. We also have 2 dell R710's that I have each individually one larger individual UPS's, but they are only the bigger desktop model ones.I am trying to get a decent runtime setup to put the 2 r710's on, and probably half the switches (6 of them total, HP procurve's 1 48, 3 24's, and 1 16port L3, and a sonicwall tz215)I was looking at the cyberpower systems backups, and they have 3kw ones with extra battery options.Can anyone make a recommendation on what...
    This topic first appeared in the Spiceworks Community

  • Is there any option to be set so that the multicolum​n list box column and row can't be editable on run time

    In my application i am using multicolumn list box. Usually while running the program the column width is editable.
    in my program i should be able to select or hightlight the row , but should not be able to edit the row or column size.Is there any property node that have to be set so that the multi column list box colum widthshould not be  editable while the program is running.
    binoy

    Can't you just right-click and disable column resize?
    Message Edited by Michael Aivaliotis on 09-19-2005 11:54 AM
    Michael Aivaliotis
    VI Shots LLC
    Attachments:
    multicolumn.gif ‏10 KB

  • Recommended method , tips and Howto for dynamics page generated on run time

    Hi all !
    I'm working on a jee5 (JPA/EJB3/JSF) application using NB6 and them VWP
    this is for the background.
    My job is to mock in Java an older app written in a proprietary language .
    Now my problem is this :
    How one can manage to create a "on-the run" edit-page = a form filled with fields which numbers and types is function of the data present in the database.
    For example record "A" of aTable presents 3 strings and 2 combos to be edited
    then record "B" due to his type presents 8 textfields 2 combos and an image and 3 address groups of fields etc...
    All these little set of pages is really dynamics, ie depends of the main table and secondary tables linked to the main record.
    So You can NOT know per advance for example that there will not be more than 10 textfields, it really have to be dynamic
    How can I succeed this in JEE ?
    I think for sure that to reach that I must forget about VWP
    That at least is obvious !
    It certainly got to be some hand-crafted code; ok for that.
    But i'm lost,
    How do I insert this besides my otherwise standard Visual Web Pack pages ?
    where should I start looking at this ?
    Can one of you put me on the trail ,
    give me some hints,
    or links me to some tutorial ...
    I've tried some googleing in vain for now...
    Thanks

    Perhaps this might help:
    How to create a table component dynamically
    http://winstonprakash.com/articles/jsf/dynamic_table.htm
    Adding components to a dynamically created table
    http://winstonprakash.com/articles/jsf/dynamic_table2.htm
    http://wiki.netbeans.org/RuntimeComponentCreation
    Radhika

Maybe you are looking for

  • Filename in import statement

    Hi srinivas bobbala, Thank you for your response.But I think my quesition was not clear.My ques... is for suppose there is one datafile for importing like.. "datafile_21" Here my intention is it takes file from datafile_21 only but it appears in impo

  • Mountain lion crash when opening logic photobooth and lost all my music in itunes.

    Why are apple apps crashing in Mountain Lion. Logic, Photobooth, iphoto and lost all my music in Itunes?

  • Mac Mini doesn't like Philips  32PF9830

    Hi all, I have a problem when connecting my Mac-Mini with the Philips LCD-TV via the DVI. I only get a blank screen, what ever I try. Here is my history: I bought a DVI-D (Dual Link, 3m = 10inch?) cable and connected it to the 9830. Immediatley I saw

  • Switcher needs External Disk help.

    I'm a new Mac user and have an issue I'm hoping I can get help with. I have a 200GB external HDD that I have partitioned. The larger partition is setup in the Mac OS Extended (Journaled) format, the smaller partition (conatining all of my info I want

  • Status blocked with workflow in purchase order

    hi colleagues I have a purc.order with status blocked at release indicator I don´t know why is 'blocked , and not released or rejected the release code says sap workflow what should I do? thanks