Runtime jar loading

Is there an easy(ish) way to take advantage of extension technology purely at runtime? I'm developing an application (so (almost) no security issues) which needs to load classes and other resources from jar files which are unknown until runtime (e.g. user types jar file's name or similar).
At the moment I'm writing a JarClassLoader because I've been unable to find one with all the features I need, but I'm getting bogged down. I basically want to add to the vm's classpath at runtime, or similar: am I missing something in the javadocs and is this actually quite simple?

I've got the same kind of problem. I have a fairly simple algortihm where I can figure out the name of the jar file from the name of the classes within it. The class names themselves are generated at runtime.
I've been trying to solve it with a subclass of java.net.URLClassLoader, which overrides findClass() to figure out when to load from one of the jar files, adds a URL using addURL() pointing to that jar file, and then calls up to the findClass() inherited from URLClassLoader's to load the class which I would expect to look in that jar file.
I'm running into problems pointing it at a local directory. I'm running this under windows and I figured I could give it a URL of "file://E:/my/local/directory/thejarfile.jar", but it doesn't quite seem to work - I think I'm just not using the URL class properly and it seems to end up with junk in there (including the string "java.lang.String" and then what looks like a memory address).

Similar Messages

  • Please remove Class-Path from kodo-jdo-runtime.jar manifest

    This is repost. Class-Path should not be in manifest of
    kodo-jdo-runtime.jar
    It causes problems with security manager when using signed jars under
    webstart. It can potentially cause all kind of other problems due to class
    path conflicts
    Seems to be a problem in manifest. It is due to Class-Path in manifest. I
    deleted manifest from kodo-jdo-runtime and signed it seems to be ok.
    I got more meaningful error now - serp.jar is missing
    I would suggest to remove Class-Path from this jar. I've seen some very
    weired behaviour of systems with Class-Path in different jars. I believe it
    should be only in your application jar
    Class-Path: serp.jar jca1.0.jar jca.jar crimson.jar xerces.jar jaxp.jar
    jdo1_0.jar jdo.jar jdbc2_0-stdext.jar jndi.jar jta-spec1_0_1.jar jta.jar
    I would also remove following:
    Main-Class: com.solarmetric.kodo.enhance.JDOEnhancer
    OpenTools-UI: com.solarmetric.modules.integration.jbuilder.KodoTools
    OpenTools-Build: com.solarmetric.modules.integration.jbuilder.KodoBuilder
    because it does not belong to kodo-jdo.runtime.jar
    "Alex Roytman" <[email protected]> wrote in message
    news:ahi05g$veq$[email protected]..
    I am having troubles running kodo 2.3 application under web start.
    I am getting following error:
    Missing signed entry in resource:
    http://ptilx1/usorg/webstart/lib/kodo-jdo-runtime.jar
    I signed kodo-jdo-runtime.jar as usual
    The same deployment worked fine with Kodo 2.2.5

    Alex-
    In article <ahk7vi$cmf$[email protected]>, Alex Roytman wrote:
    This is repost. Class-Path should not be in manifest of
    kodo-jdo-runtime.jar
    It causes problems with security manager when using signed jars under
    webstart. It can potentially cause all kind of other problems due to class
    path conflictsThanks for the feedback. We will remove the entries. In general, it is nice
    to have it in the Class-Path, since they you only need to
    kodo-jdo-runtime.jar in the CLASSPATH variable, but we were not aware of
    it causing any problems.
    Seems to be a problem in manifest. It is due to Class-Path in manifest. I
    deleted manifest from kodo-jdo-runtime and signed it seems to be ok.
    I got more meaningful error now - serp.jar is missing
    I would suggest to remove Class-Path from this jar. I've seen some very
    weired behaviour of systems with Class-Path in different jars. I believe it
    should be only in your application jar
    Class-Path: serp.jar jca1.0.jar jca.jar crimson.jar xerces.jar jaxp.jar
    jdo1_0.jar jdo.jar jdbc2_0-stdext.jar jndi.jar jta-spec1_0_1.jar jta.jar
    I would also remove following:
    Main-Class: com.solarmetric.kodo.enhance.JDOEnhancer
    OpenTools-UI: com.solarmetric.modules.integration.jbuilder.KodoTools
    OpenTools-Build: com.solarmetric.modules.integration.jbuilder.KodoBuilder
    because it does not belong to kodo-jdo.runtime.jarCorrect again: we will remove it in the upcoming release.
    "Alex Roytman" <[email protected]> wrote in message
    news:ahi05g$veq$[email protected]..
    I am having troubles running kodo 2.3 application under web start.
    I am getting following error:
    Missing signed entry in resource:
    http://ptilx1/usorg/webstart/lib/kodo-jdo-runtime.jar
    I signed kodo-jdo-runtime.jar as usual
    The same deployment worked fine with Kodo 2.2.5
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com
    Kodo Java Data Objects Full featured JDO: eliminate the SQL from your code

  • I am trying to upload new version iTunes into Windows 7 and getting error message that runtime is loading incorrectly. Cannot connect to online support. Any ideas please?

    I am trying to upload new version iTunes into Windows 7 and getting error message that runtime is loading incorrectly. Cannot connect to online support. Any ideas please?

    See Troubleshooting issues with iTunes for Windows updates.
    tt2

  • Where is the JavaFX runtime jar file in jdk7u4

    So I find jdk 7u4 release notes:
    The JavaFX SDK is installed with Java SE 7 update 4 for both the Windows and Mac OS X platforms. The JavaFX Runtime is installed with the JRE for the Windows platform.But I can't find the javafx runtime jar file, jfrt.jar? anybody can tell me where javafx runtime jar file locate.

    It's a co-install. If you don't find the Oracle directory in Program Files or Program Files (x86), then you might have opted out of the JavaFX side of the install.
    I had done this and had to uninstall Java7, then reinstall and opt-in the co-install.
    Another thing which can trip you up is if you have installed a later version of JavaFX (2.2 beta). In that case, you may need to uninstall both java and javafx and then complete the co-install.
    I'm really looking forward to the day when JavaFX is ubiquitous and part of Java proper, but for now, there is a little bit of pain.
    - Pat

  • Should IDE integration classes be in kodo-jdo-runtime.jar?

    Should IDE integration classes be in kodo-jdo-runtime.jar? or even in
    kodo-jdo.jar? they probably should go to a separate jsr

    Probably. We're moving the integration stuff (ide and ant) out at some point
    soon.
    On 6/6/02 12:29 AM, "Alex Roytman" <[email protected]> wrote:
    Should IDE integration classes be in kodo-jdo-runtime.jar? or even in
    kodo-jdo.jar? they probably should go to a separate jsr
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Any way of modify base directory at runtime (in loaded jars )?

    Hello all,
    Well, I'm using tomcat to run my web application, which loads
    dinamically many jars and execute them. My problem is that these jars
    sometimes have a method that uses relative paths to do something (read
    files, create files, etc). Currently, the current base dir is given
    wrong for these loaded applications! Instead of the right path, it's
    given "C:\tomcat" or something.
    If it were with my Web Application itself, it would be easy to get over
    this problem by using the getRealPath("") method provided by api. But
    since I can't modify the jar code I will load, what can I do? Some
    ideas?
    Thanks you!
    Bruno

    I have found the solution. This is the code to write-access files from within JavaServer Faces backing bean:
    FacesContext fc = FacesContext.getCurrentInstance();
    ExternalContext ec = fc.getExternalContext();
    ServletContext sc = (ServletContext) ec.getContext();
    String realPath = sc.getRealPath(getDocumentURI());
    FileOutputStream fos = new FileOutputStream(realPath);where getDocumentURI() is the method that returns the virtual path for document to write to.

  • Dynamic Jar Loading Issues

    Background: I'm writing a program that downloads modules (jars) from a server.
    MainProgram contains the following interface
    public interface Action{
        public void go();
    }The main program gets appropriate class names from a database and loads them using JarClassLoader (found at http://www.javaworld.com/javaworld/javatips/jw-javatip70.html). It then instantiates and runs the go() method on each class. This works great, but...
    If I'm within one of these "loaded" classes and I want to use another "loaded" class I can't. If I just do a "new Foo()" it compiles, but I get a "NoClassDefFoundError". If I load the class out of the jar file with JarClassLoader (which worked to load the class I'm currently running in) it works until I try to cast it, then I get the same error. I'm wondering if the loaded classes aren't in the classpath, so I can't use them unless they extend a class that's in the classpath. In this link, http://forum.java.sun.com/thread.jspa?threadID=5117586&tstart=0 , there's talk of adding classes to the classpath at runtime. I even found an interesting example: http://marc.theaimsgroup.com/?l=ant-dev&m=115809243322706&w=2 , but someone mentioned that the addUrl method being used is not public and might change in later versions.
    Questions: If I use the addUrl method, will I be kicking myself later? ('cause I kick hard) Or is there a better way to do this that I'm missing? (this second option seems to occur a lot)

    Well I FINALLY got the URLClassLoader's addURL method to work and the JavaDoc says it's protected it, so if they change it in the future they will seriously anger anyone who overrode this method. Thanks anyway!

  • Controlling  JAR loading order in OC4J

    I have a WAR file ,which contains 2 JAR files namely, BASE.JAR, IND.JAR(among others).
    BASE.JAR is used in our base application and IND.JAR is the industry specialization of BASE.JAR.
    IND.JAR & BASE.JAR do have many overlapping classes.
    In my industry application WAR ,i neeed OC4J to load IND first and then look at BASE. that way i will always invoke the IND variant and then if a class is not in IND then BASE gets invoked.
    how do I set this ? ( weblogic has a load order ,does OC4j have anything like that ?).
    Thanks in advance.

    Hello,
    If your application can be packaged into an EAR file I recall sometime I employed the standard application.xml file (that tells the container to load each module in the order specified therein).
    Nevertheless that addresses a deploy time issue, not runtime like this one. If you are using OC4J 10.1.3, you can edit the deployment plan for your WAR file; in the webAppClassLoader wizard you can change the "searchLocalClassesFirst" or "includeWarManifestClassPath" setting. By finding adequate values for those above and by using the shared libraries mechanism accordingly you may work it out.
    RB

  • HT5654 Help.     A failed update to ITunes has stopped me gaining access to ITunes. "Error7 (Windows error 1114)". " R6034 C runtime library loaded incorrectly". What can i do? I'm not computer literate!

    Today i received a prompt from Apple to download the latest ITunes update. I did so and received a message that the update had failed. Now i cannot gain access to ITunes on my computer or play any of my music files associated with ITunes. I just keep getting the following 2 messages:-
    Itunes not installed correctly. Please reinstall ITunes. Error 7 (Windows error 1114).
    Runtime Error. Program:c:\Program Files\ITunes\ITunes.exe.  R6034 Application made attempt to load C runtime library incorrectly. Contact application's support team.
    I have many tunes in my ITunes library & playlists which i do not want to lose. I am not computer literate and am afraid if i simply download the latest version of ITunes from the web, it may result in erasing those tunes.
    Can anybody help me out please ?

    Go to Control Panel > Add or Remove Programs (Win XP) or Programs and Features (later)
    Remove all of these items in the following order:
    iTunes
    Apple Software Update
    Apple Mobile Device Support (if this won't uninstall move on to the next item)
    Bonjour
    Apple Application Support
    Reboot, download iTunes, then reinstall, either using an account with administrative rights, or right-clicking the downloaded installer and selecting Run as Administrator.
    The uninstall and reinstall process will preserve your iTunes library and settings, but ideally you would back up the library and your other important personal documents and data on a regular basis. See this user tip for a suggested technique.
    Please note:
    Some users may need to follow all the steps in whichever of the following support documents applies to their system. These include some additional manual file and folder deletions not mentioned above.
    HT1925: Removing and Reinstalling iTunes for Windows XP
    HT1923: Removing and reinstalling iTunes for Windows Vista, Windows 7, or Windows 8
    tt2

  • Adobe AIR dist. Runtime not loading MyApp.air

    Hi
    I've got the License Agreement & have been sent the link to download the Air distribution files.
    My project is a CD ...
    OSX portion works ok ... Run Air dist app, installs Air if ness... then installs MyApp.air .
    WIN side of things, no luck .
    I've got .airinstall.cfg pointing to MyApp.air in a test folder with the Air Runtime distribution file .  Double click runtime & it says either "Adobe Air already installed" & then quits, MyApp.air not loaded ... or ... Installs Air runtime & then quits, MyApp.air not loaded (depending on if Air installed/not) .
    Theoretically all you need is 3 files in a directory : AdobeAIRInstaller.exe, .airinstall.cfg, MyApp.air & it should work, is this correct?
    Tried the side-car method (not sure what end difference is) & get message :
    "This application cannot be installed because this installer has been mis-configured. Please contact the application author for assistance."
    When double-click MyApp.air it works/installs fine .
    Am I missing something ?

    Turns out I hadn't been using an up-to-date installer ... dur

  • Recently I did an update and now can't open iTunes.  I get a Runtime Error telling me C Runtime library loaded incorrectly.  Please help?

    Recently, I did an update on iTunes on my Acer laptop. Now I can't open iTunes & I get a Runtime Error telling me C Runtime library is loaded incorrectly.  I have Windows 7 64-bit. Do I need to reinstall iTunes.

    Hi sungoddess69,
    Thanks for visiting Apple Support Communities.
    To resolve this error, I recommend completely removing and reinstalling iTunes and all of its related components using these steps:
    Check for .dll files
    Go to C:\Program Files (x86)\iTunes and C:\Program Files\iTunes and look for .dll files.
    If you find QTMovie.DLL, or any other .dll files, move them to the desktop.
    Reboot your computer.
    Note: Depending on your operating system, you may only have one of the listed paths.
    Uninstall and reinstall iTunes
    Uninstall iTunes and all of its related components.
    Reboot your computer. If you can't uninstall a piece of Apple software, try using the Microsoft Program Install and Uninstall Utility.
    Re-download and reinstall iTunes 11.1.4.
    You can find the article with these steps and more information here:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Best,
    Jeremy

  • Is the whole jar loaded for a single class?

    Hi,
    Hopefully this is an easy yes/no question.
    If my application makes reference to only a single class in a jar that has many other classes, does the entire jar (all the other classes) get loaded into memory?
    If so, then it's worth it to break the jars up into only those classes I need (they're third party jars). Otherwise, I'll have to look for some other solution.
    TIA.
    Mike

    No you don't.Yes he does - he was big enough to admit it - can't you?
    import xyz.* doesn't "load everything in memory" as
    schapel stated. You better read chapter 1 of your book
    again (and again until it sinks in) before answering
    advanced forum's questions.Perhaps you should reread schapel's post before making hot-headed replies to the advanced forum's questions. Besides, you must not read these forums too much because this topic comes up a lot.

  • Problem Compiling JAR Loaded in Oracle 10g

    I have loaded a JAR file into my Oracle 10g database using the following command-line:
    Loadjava -force -oci8 -order -resolve -schema "MYSCHEMA" -user "USER/PASSWORD@HOST" -verbose "JarFile.jar"
    Unfortunately, after loading the JAR contents, the resolution of the individual files never completes. The process runs for >24 hours. Is there a better way to complete this task? I have even tried compiling portions of the JAR file via Toad, but it appears the recursive nature of the dependencies causes the process to essentially hang.
    Unless the JAR files compiles successfully, I can load my Java source code but my resulting Java stored procedures cannot compile because of my import references to the JAR file. My java code was compiled for JDK1.3 using JDeveloper 10.1.3.0.0 to eliminate conflicts with the Oracle JDK (JDK1.4). Is there a setting or a flag which would allow compilation of my source code without compiling the JAR file to utilize the Oracle JIT compiler?
    Any assistance/suggestions would be greatly appreciated. Thank you.

    Avi,
    Thank you for the suggestion. As a result, I found how to load my JAR (iText JAR file) file without decompressing using loadjava -jarasresource MYJAR.jar but now the issue of referrencing this resource within my Java class so that it will compile once loaded into the database. Here is sample of my objects:
    Oracle User-Defined Type:
    CREATE OR REPLACE TYPE schema."BLOB_ARRAY" as varray(20) of BLOB
    Java Source:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED schema."JavaSource" AS
    import com.lowagie.text.Document;
    import com.lowagie.text.pdf.PdfCopy;
    import java.io.ByteArrayOutputStream;
    import java.io.*;
    public class JavaSource{
    public static Document doc;
    public static ByteArrayOutputStream baos = new ByteArrayOutputStream();
    public JavaSource(){}
    public static PdfCopy getDoc(oracle.sql.BLOB[] docs){
    PdfCopy writer = new PdfCopy(doc, baos);
    return writer;
    LOADJAVA:
    loadjava -force -schema "SCHEMA" -user "user/password@sid" -verbose -resolve -unresolvedok -genmissing -jarasresource -genmisingjar "C:\JavaSource.java" "C:\iText.jar"
    Oracle Package:
    CREATE OR REPLACE PACKAGE schema."JavaSource" AS
    FUNCTION getDoc(param1 schema.BLOB_ARRAY) return PdfCopy AS Language Java Name 'JavaSource.getDoc(oracle.sql.BLOB[]) return PdfCopy';
    Oracle Function to query Database populating User-Defined type argument:
    CREATE OR REPLACE FUNCTION schema.TestRun() RETURN schema.BLOB_ARRAY AS
    tmpArray schema.BLOB_ARRAY := null;
    BEGIN
    tmpArray schema.BLOB_ARRAY := BLOB_ARRAY();
    cursor c_blob is select blob_content from schema.doc_table;
    BEGIN
    for blob_rec in c_blob loop
    tmpArray.extend;
    tmpArray(tmpArray.count) := blob_rec.blob_content;
    end loop;
    END;
    return tmpArray;
    END;
    I cannot get my class JavaSource to compile as VALID and therefore the Oracle Function schema.TestRun does not execute properly. Am I missing something? Assistance is greatly appreciated. Thank you.

  • Runtime Error  loading Crystal Reports 2008

    Hi there
    I have recently purchased online in the sap site the bundled product that includes SAP Crystal Reports and SAP Crystal Dashboard Design on the sap website. For those I received only one key code
    I downloaded both products and manage to installed and load SAP Crystal Dashboard Design. I have installed SAP Crystal Reports (CR2008LPs_02142011.exe) everything goes well. When I start the program it loads for a second and then I get the following error:
    u201C Runtime Error!
    Program: c:\Program Files\Businessu2026
    This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application support team for more information.u201D
    My OS is Windows 7 Enterprise 32-bit
    I have tried the following:
    u2022     Uninstalling and reinstalling again
    u2022     Downloading the file again from the sap site in case the file was corrupted
    u2022     I have uninstalled CR and download the SAP Crystal Reports trial version from SAP site
    u2022     Trying to navigate to the registry to clear the registry for recent files (as I have seen in this thread Crystal Reports 2008 Runtime Error) . I get the following error message when I click on u201CHKEY_CURRENT_USER/Software/Business Objects/Suite 12.0/Crystal Reports/Recent Filesu201D. Error:
    "Error opening Hey:
    Crystal Reports cannot be opened
    An error is preventing this key from being opened
    Details: Access is denied"
    I have been unsuccessful with all the above.
    I would appreciate if someone could help.
    Thanks in advance and regards,
    Santiago

    Hi Santiago,
    That error suggests you are not a local PC administrator. CR installs require you use an account that can update registry keys etc.
    Talk to your IT guys to give you full access to your PC or log on as the local PC Administrator and install it again.
    Thank you
    Don

  • Dynamic jar loading

    Hello,
    I have a java application which should accept the three parameters.
    1) The jar file location
    2) Particular Class file insdie that jar(we specified the location in step number 1)
    3) And method name in that class.
    My question is how to include specified jar location with jar name to CLASSPATH at run time. So that i can execute a particular method name in step number (3).
    I would appreciate for the quick reponse or any input.
    Thanks,
    Raghu

    You cannot change CLASSPATH at run time, but you can:
    1) create a class loader
    2) load the class from there
    3) use reflection APIs to invoke the method.
    The key here is the class loader class, usually this one:
    http://java.sun.com/j2se/1.5.0/docs/api/java/net/URLClassLoader.html

Maybe you are looking for

  • IE7 running on Vista will not let me load Shockwave

    It will not load. As I try to load Shockwave, I get an error message "Internet Explorer has Stopped Working" then in my Systems Tray I get a message "Data Execution Prevention has stopped a progarmme from loading". Help, how can I get around this pro

  • Patch installation problem...

    Hi, My database is running on Linux.Database version is(9.2.0.4). I have to upgrade database from 9.2.0.4.0 to 9.2.0.6.0. I tried to apply P3948480_9206__Linux.Zip this patch. After unzipping this patch , $./runInstaller Checking Installer Requiremen

  • Really anooying memory card/gallery problem nokia ...

    Hey guys this is the 3rd time this has happened since i got my new nokia n73 i read some reviews about the nokia n73 and the cons are that its sometimes slow and lags. Well after i take a video or photo and i hit the red end call button ( it works ju

  • Dreamweaver deletes code in head!

    Hi there! This is my first question to the group and I hope it's not too silly for the experts... My problem is that Dreamweaver (it happens with MX 2004 but also with Dreamweaver 8) deletes code from the head. I have defined an editable region, usin

  • SSM KPI Security:Restricting the measures to Users

    Hi I want to restrict only few KPIS(measures) to be accessed by a particular user. I was able to restrict only 22 measures(4 KPIs), beyond which i get an error.But this user should be able to access 20 KPIs(20*5 measures).  The syntax that i used: IN