Load a resource in a jar from another jar file

Hello, everyone!

Suppose I have two pots: jar1.jar and jar2.jar. jar1.jar references jar2.jar in its manifest file. jar2.jar has a file META-INF/some - file.xml. Now I would like to know what is the best way to load this resource (some - file.xml) for a class in the jar1.jar file. I know that I can call:
ClassLoader.getSystemClassLoader().getResource("META-INF/some-file.xml");
but I've heard say that by using the system class loader is not recommended, because your code could not work if you move it in an Enterprise JavaBean, a Web application or a Java Web Start application:

http://www.JavaWorld.com/JavaWorld/javaqa/2003-06/01-QA-0606-load.HTML?page=1

So I would like to know what is the best way to load this resource in this case. Or is it the way you would?

Thank you.

Marcos

Good, then you don't want to use the system class loader. So, your question is what class loader, you must instead use? I prefer to keep things simple so I would use the class loader of the class, in that the code is located. So:

this.getClass().getClassLoader().getResource(...)

Also, it makes no difference if the code in question has been loaded from a jar file or elsewhere. Once it runs, it is in memory. Don't try not to get distracted by rubbish, it is quite difficult to do things without it.

Tags: Java

Similar Questions

  • Import symbols from another .fla file

    Hello

    I've looked everywhere, until I got bored. Is there a way I can import symbols from another .fla file? For my game, I have a file named background.fla which has several origins and I want to import from it and modify it if necessary. Is there a way I can do?

    Also after I read if I want to import a .swf file in my main .fla it will lose all of its code, but I want to import a character and use it with gotoAndPlay() and gotoAndStop().

    I have a last question if you don't mind, I have the knowledge base of OOP and I know it's imposible: I want to create a class, create an instance of it in my main .fla and somehow this class controls the code in my main file. I found a way with timers, but it's pretty expensive on memory...

    Thank you for your time (^^)

    Yes, you can do it dynamically, too.  check the applicationdomain class.

  • Flash as2 cross subject to access the SWF from another server domain

    I have question cross-domain, how do I access the .swf from another swf file without using System.Security.allowDomain() in the swf file, which we are called.

    I use 2 domains and I have 2 files swf is a.com (a.swf) and another is of bcom (b.swf) I want to access the file the a.swf b.swf frames, if I use the system.Security.allowDomain() in b.swf file I can access executives. But without using this way I can access the file from another domain.

    Because I have a risk to change the file b.swf so I vant to go without changing the file b.swf is any other wey to access frames of the file the file a.swf b.swf. Please someone help me solve this problem.

    use a local executable (such as php) to load the b.swf and send it back to a.swf.  for example:

    loadSWF.php:

    <>

    $fh = fopen ("www.b.com/b.swf", "r");

    Header ("Content-type: application/x-shockwave-flash");

    fpassthru ($FH);

    ?>

    a.fla:

    var target_mc:MovieClip=this.createEmptyMovieClip("target_mc",this.getNextHighestDepth());

    target_mc.loadMovie ("loadSWF.php");

  • Load a picture 2D from a txt file

    Hi, I have a little problem on the table: /.

    I'm a little game of tiles according to the coding, and I load the map from a .txt file.

    The txt file is like this:

    0 1 0 1 0 1 0 0 0 0 0 1 1 1 1

    1 0 1 0 1 0 0 1 1 0 1 0 1 0 1

    ...

    and I want to just use it in this loop:

    for (var i: int = 0; i < mapHeight; i ++)

    {

    for (var j: int = 0; j < mapWidth; j ++)

    {

    var cell: MovieClip = new tile();

    cell.gotoAndStop (map [i] [j] + 1);

    If (i % 2 == 1) {}

    Cell.x = 70 * j - 35;

    Cell.y = 35 * i;

    }

    else {}

    Cell.x = 70 * j;

    Cell.y = 35 * i;

    }

    addChild (cell);

    }

    }

    This loop works if I create the table on the map in the AS3 file, but with 10 cards, the code will be very very very long.

    I tried to load the table from a txt file, but there is not a lof on internet information and I'm stuck.

    To load the txt file:

    var mapLoader:URLLoader = new URLLoader();

    mapLoader.addEventListener (Event.COMPLETE, onLoaded);

    function onLoaded(e:Event):void {}

    var maptext:String = e.target.data;

    var map: Array = maptext.split("");

    trace (Map);

    }

    mapLoader.load (new URLRequest ("map1.txt"));

    But I do not understand how to use 'map' after that, I can't use it in the loop to add cell, I have an error.

    I find that all it really complicated to load just a simple table 2D from a txt file.

    Can't I just put all the maps in AS3 in a different txt file and load this part of code when I need it? Like this:

    "var map: Array = [];

    [1,0,0,1],

    [1,1,1,1]

    [0,0,0,0]

    [0,1,0,1],

    ]; "

    Thanks for the help and sorry for the bad English.

    If I recreate the first version, I get the same result as what you show for the second version - I do not get the result snapped up as show you.  My guess is that you have the data file prepared incorrectly when you organize the data into it.

  • I can automatically fill a PDF form with data from another file of the Government?

    I need to be able to insert automatically the data into a PDF form to print.  I can create the data file with alpha and numeric values to be inserted into the form.  Is there a way to merge/package/combine without action from the user to slide, falling, or gluing?

    It would be on a platform Windows (ideally for XP and Windows 7).

    Hi Mike,.

    Yes you can import data to a PDF file from another data file using option "Import data" in Acrobat. AXI supports the .fdf, the .xfdf, the .xfd, .xml and .txt file formats. I'm not sure the version of Acrobat you have, but here I am you provide the links of the AXI and AX online help documentation. Please post back if you need more information:

    AXI: http://help.adobe.com/en_US/acrobat/using/WSE8580964-0716-4452-BA8D-EA9AAD3F6091.html#WSDD 95883E-EB9B - 409 b-8C7C-33E0DAE68FFE

    AX: http://help.adobe.com/en_US/acrobat/standard/using/WSDD95883E-EB9B-409b-8C7C-33E0DAE68FFE. html

    ~ Sandeep V.

  • How to create Maste Scrpt to call/execute another sql file

    Hello

    Can you please help me on below.

    I have 10 different .sql file and wanted to run in a sequence of another .sql file. Need sample file I can send it back to create my file master sql to call anothere Stored proc or .sql to comiple.

    as:

    a.SQL

    b.PRC

    c.PKH

    c.PKB

    d.SQL

    watnted to run these files from another .sql file, do I need to mention the path, if yes then how to define the path, the execution of another file. all sewage treatment.

    forward, thanks in advance

    Thank you

    Rob

    Hi, Rob.

    885137 wrote:

    Hello

    Can you please help me on below.

    I have 10 different .sql file and wanted to run in a sequence of another .sql file. Need sample file I can send it back to create my file master sql to call anothere Stored proc or .sql to comiple.

    as:

    a.SQL

    b.PRC

    c.PKH

    c.PKB

    d.SQL

    watnted to run these files from another .sql file, do I need to mention the path, if yes then how to define the path, the execution of another file. all sewage treatment.

    forward, thanks in advance

    Thank you

    Rob

    To call SQL scripts from another SQL script, do the same thing you would do to call by typing on the command line.  Put the @ symbol immediately before the name of the file:

    @a

    @b

    @c

    ...

    You don't need to say "@a.sql", ".sql" being the default value at the end of the file name.  If you find that explicitly ".sql" in the script, it is clear, then, by all means, go ahead.

    If you do not include a full path name, SQL * Plus assumes that they are in the default location.

    If you use 2 @ signs, then SQL * Plus will assume the Sub-script is in the same folder (directory) as the main script running, so you can say

    @@a

    @@b

    @@c

    ...

    How to include a path depends on your operating system. In Windows, for example, you could say:

    @d:\sql_scripts\sales\a

    @d:\sql_scripts\research\b

    ...

    Instead of the sign @, you can use the START command.

    See the SQL * Plus manual to learn more:

    https://docs.Oracle.com/database/121/SQPUG/ch_five.htm#sthref439

  • I bought a new hard drive. I don't have a system recovery disk. Can I load Windows Vista from another source and activate using my original product key?

    I bought a new hard drive. I don't have a system recovery disk. Can I load Windows Vista from another source and activate using my original product key?

    Hello

    There is no download available from Microsoft Vista.

    Contact the manufacturer of your laptop and ask them to send a set of recovery disks.

    They should do this for a small fee.

    "How to replace Microsoft software or hardware, order service packs and replace product manuals.

    http://support.Microsoft.com/kb/326246

    Some manufacturers have more available Vista recovery disks.

    If this happens, you may need to try this instead:

    You can also borrow and use a Microsoft Vista DVD, which contains the files for the different editions of Vista (Home Basic, Home Premium, Business and Ultimate) must be installed. The product key determines which Edition is installed.

    Builders recovery DVDs are should not be used for this purpose.

    And you need to know the version of 'bit' for Vista, as 32-bit and 64-bit editions come on different DVDs

    See you soon.

    p.s. If the old hard drive is still installed and running before you change on hard drives and you never received the to purchase recovery discs, you can make the recovery discs from the recovery Partition which should be on the old hard drive. You will need to request that the manufacturer how to do as each computer manufacturer has their own way of making records of this partition recovery.

    It depends on the old hard drive still works.

  • Homegroup is very slow. Loading files from another computer is very long and I can't watch movies on the wireless using the homegroup.

    Group residential slow and other problems with it

    Hello!

    I have 3 Windows 7 PC-s (office #1, #2 desktop and laptop). I created HomeGroup and join all computers, so I can access the files on each of them. But my problem is the following: homegroup is very slow. Loading files from another computer is very long and I can't watch movies on the wireless using homegroup, because it is slow and every two seconds of loading film. And also needed a few minutes to open the pictures (more than 10 GB in all folders) to a folder in the other PC. Why is this work so slow? I don't think there is a problem with slow wireless router, because I can replace my old Linksys WRT54GL Linksys E4200, which is able to transfer video HD 3D such as Linksys provide. What should I do to fix this? Should I change all the settings in Windows, perhaps in the router...?
    And why my laptop is not always visible to the other PC to homegroup? He see two others and two other sees, but they are not portable. This happens sometimes. But then I still share with homegroup libraries to my laptop and there still other computers see it and all shared libraries. Where is the problem? I also try to change the HomeGroup services automatically, but this does not solve the problem.
    If I forgot something to write, or you need more information, do not hesitate to ask.
    I'd appreciate any help really.

    Hello

    Manually check manufacturers sites WiFi because pilots offered through
    Updates Windows will most often not be later (MS is far behind certifying)
    drivers and many manufacturers do not quickly submit newer versions or not at all). See
    Manual driver update of the methods below.

    The question could be WiFi in fact however try to device (hardware)
    update the driver first.

    What antivirus/security is used? Some of those who will cause problems with the
    Homegroup. Since it happens more often on a single computer that on there
    a check.

    From this link:

    Homegroup: frequently asked questions (also shows how delete and remove homegroup)
    http://Windows.Microsoft.com/en-us/Windows7/HomeGroup-frequently-asked-questions

    "Only people who belong to the homegroup can see shared libraries. You can also share libraries or files and individual folders with specific people in your homegroup, rather than share them with everyone. For more information, see libraries with your homegroup sharing and keep files and folders to be shared with a specific residential group. »

    Share files with anyone
    http://Windows.Microsoft.com/en-us/Windows7/share-files-with-someone

    ==================

    How to upgrade manually the drivers:

    Control Panel - network - write down of the brand and the model of the Wifi - double click top - tab of the driver - write
    version - click the driver update (cannot do something that MS is far behind the pilots of certification). Then
    Right click on the Wifi device and UNINSTALL - Reboot - it will refresh the driver stack.

    Look at the sites of the manufacturer for drivers - and the manufacturer of the device manually.
    http://pcsupport.about.com/od/driverssupport/HT/driverdlmfgr.htm

    Installation and update of drivers under Windows 7 (updated drivers manually using the methods
    below is preferred so that the latest drivers from the manufacturer of system and device manufacturers are
    found)
    http://www.SevenForums.com/tutorials/43216-installing-updating-drivers-7-a.html

    Download - SAVE - go where you put it - right click – RUN AS ADMIN.

    You can download several at once however restart after the installation of each of them.

    After watching the system manufacturer, you can check the manufacturer of the device an even newer version.
    (Those become your fonts of rescue system manufacturer).

    Repeat for network (NIC) card and is a good time to get the other updated drivers as windows
    7 love the updated drivers.

    I hope this helps.

    Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="" -="" mark="" twain="" said="" it="">

  • Loader will load the images from another server, but then we get error on Bitmap operation

    I develop an application that currently uses Loader to get the images to another server.  This should not work now because we are still waiting for the owner of that server to put a crossdomain in place file.  However, it works - sort of .

    Charger can load the images very well, without error.  But then the application has a feature that we are a great duplicate of the image to display in a sidebar, we do this in this way:

    var myBitmap:Bitmap = Bitmap (loader.content);

    and when will we get a Flash player 2122 security error, violation of sandbox.

    So although I hope that all this will fix itself when the crossdomain.xml file is set up, I am confused as to why we get only the sandbox error when we do a bitmap image, and not when we try to initially retrieve the image.

    (By the way: is there a better way to make a "copy" of an image loaded by a loader and change its width and height to display simultaneously in another part of the scene?)  "I have need to change its real dimensions - I just need to change its display width and height).

    Thank you!

    The sandbox allows you to view, not not editing from another server without a cross-domain.

    Therefore, when you try to load up, it loads, it 'read only' and gives you an error when you try to "change" by a new Bitmap out of it.

    This should resolve itself once crossdomain is in place.

    || EDIT |

    I just realized that I have to clarify my statement a bit more.

    When you load images from another server without a crossdomain, it only allows the load for display.  When you try to load data, it will fail.  It is because that data XML, or another type of data is editable by default, and the images are only visible by default.  As a result, the image fails when you try to convert it to an editable form.

  • getBytesLoaded() and getBytesTotal() return anything when you load content from another domain

    I created a movie that load various media using loadMovie(), then in many cases performs actions on the newly loaded MCs once loading is completed. I rely on getBytesLoaded and getBytesTotal to know when to perform these actions.

    This works very well when the content is on the same server as the film, but I also need to load content from another domain and this is where it falls apart. The media actually does very well in the target MCs, but never make the functions that need to be running when the loading is complete. The problem is that getBytesLoaded() and getBytesTotal() both return nothing when the content is loaded from another domain.

    I'm stuck with loadMovie and getBytesLoaded/getBytesTotal as this film must be published for Flash Player 6, but I actually tried to use loadClip() and onLoadInit() and I get the same problem - onLoadInit() never works.

    Another weird thing is that test by displaying a flash preview is not displayed this problem - the content of fines and getBytesLoaded and getBytesTotal loads two values to return as expected. It's only when I publish the film and display in a browser I have this problem.

    Where I'm going wrong?

    Thank you!

    in your external SWF on the other server, type the following in the first picture...

    Code:

    System.security.allowDomain (_parent._url);

    If you load your swf file into a movieclip with instance name mcImage and then do

    Code:

    System.security.allowDomain (mcImage._url);

  • Import data from another browser - only a few favorite IE9 are transferred in bookmarks. Solution HTML - HTML file all Favorites OK, but same result

    Win7 / IE9: use for the first time. Example: A folder of Favorites has 4 entries HTML - only 2 transferred. Some have none transferred - empty folder. Others have correct random + some disappeared persons.

    All of Monday
    I can see the full list of favorite IE9 HTML in HTML file on desktop with Firefox-> new tab-> open file-> open
    .
    In the desktop HTML file, there are 37 files IE9 with no more nesting 3 deep in all of a high. They are all correct wrt favorite IE9.

    All records albums + deeper nests are copied in FF ok. Random content. Copied content works ok

    7 unassigned to IE9 HTML web sites best records are also copied <-these 7 copy on FF and work well

    Example: First file in the list of IE9 has no nesting., IE9 has 4 entries - Firefox has only 2. What other method of reproduction is used.

    BTW - please let know us how I can delete entire list of bookmarks in Firefox button to try again with a clean list of bookmarks

    I'll uninstall Firefox and start over with a clean copy and use the HTML only method to try to transfer IE (files. I'll bring result.

    BTW, I'm in the United Kingdom at the time of UK - where delays to answer - need to sleep sometime!

    Tuesday night

    Hello

    I uninstalled Firefox. Re installed and loaded with favorite IE9 to HTML file.

    All seem to be copied correctly

    First time that I started using the "import data from another browser. Partial is copied.
    Then I tried 'Import HTML file' without deleting any favorite had been copied. Always partial copied.

    Everything seems fine.

  • Satellite A100-549: BSOD after I used the recovery from another PC

    Hello.

    Had a few probs with my laptop and decided to recover it using another pc recovery disc.
    I get the laptop is a Toshiba a100-549. Unfortunately for some reason I can't disks that were originally with her.

    The opertaing system is Windows xp. The disks I got with a Vista.
    It loads OK but goes to a blue screen after 30 seconds and restarts. Is there a reason for this and can I do.

    I think I may need to get your hands on a good drive and load it on again.
    Someone at - it copies of drives for this laptop and able to send me their. I'll gladly pay for them...

    Colin

    Hello

    Don t user recovery drive to another PC, because it won't work.
    You can use a clean Windows OS disk or the Toshiba recovery disc.

    Why? Because the recovery disk contains an image. The image is a package containing a Windows OS, drivers and other software.
    If you want to use the recovery from another PC disk then all the drivers, tools and software distributed for this PC will be loaded on your Toshiba laptop.
    This can cause the BSOD!

    So if you n t have the Toshiba recovery disc then you should use MS Windows CD!
    Toshiba drivers can be downloaded from the Toshiba page!

  • Desktop H500s put in the disk hard windows 10 from another OPERATING SYSTEM PC - ERROR CODE 1962 - No.

    I tried to replace the current hard drive with the disc provided with windows 10 from another PC.

    I have is after having swapped the hard drive. The system cannot load Windows 10 and displays this message "ERROR CODE 1962 - No. OPERATING SYSTEM".

    The main reason I like to swap the drive is because it is a larger and faster disk and it come with Windows 10 Enterprise license. Instead of my current hard drive of Levono who only 8.1 Windows

    I understand that the pilot is maybe a problem. But, I should at least be able to see the Windows screen and I can fix it the driver, instead of the message "ERROR CODE 1962 - No. OPERATING SYSTEM"

    Note: I did I tried to put this disc in the CD player, I've found, it can read the disc. Therefore, should not be SATA non-compliance issue.

    Any suggestion?

    Hope to hear the suggestion

    Dear all

    I managed to fix in Boot "Disable UEFI and activate the legacy", my system is running. I just need to install the audio driver after the system is running

    Usefully it doesn't matter who will help to have the same problem

  • BlackBerry Smartphones to install the Firmware from another provider?

    My operator: Rogers

    Device: 8900

    Environment: BES Express 5.0.1

    I need to install Device Software 5.0 to synchronize my public folders wireless.

    Rogers only has not the 5.0 firmware updated. However, I found it for the 8900 on Vodafone UK downloads.

    No damage in this load?

    Operating system device provided are "released" by specific carriers once that they are certified and trained to their support technicians, but still, you are able to load any carrier the same model by following the instructions below.

    Some users might worry that they will void their warranty of device by loading an OS from another carrier. There is really nothing to fear. Read more information on it here:
    http://www.port3101.org/power-users/296-BlackBerry-OS-upgrade-including-betas-myths-dispelled.html

    Make a backup of your device first, using Desktop Manager > backup. Close the office at the end Manager.

    1. download the OS files to the PC then install on the PC by running (double click) the downloaded file.
    2. go in c:\program files Research in motion\apploader and delete the file named "vendor.xml."
    3. plug in the BB and double-click on "Loader.exe." It is located in the same place as the above vendor.xml file.

  • Oracle Database XE - apex on Windows 7 - the problem with the connection from another computer on Windows 7

    Hello

    I started with Oracle Database 11g, with apex XE, fact the upgrade of the Apex 4.2.6 and to develop a small Application.

    I wanted to connect to my computer (with step of database on this subject) from another computer Windows 7 B.

    So I put Firefox: //A:8080/apex but I have only received a timeout.

    Of course, on both computers there is a firewall of windows running, so I stopped on both systems, the firewall, but it is always the same.

    In Explorer windows running on computer B, I can see data from computer A and both computers are in the same home-net group. (Sorry for my bad English).

    Is there anyone who cann tell me how to get the connection running?

    Maybe I saw the info on this in the textbooks, if it is there, please give me a hint.

    Thank you very much

    William Kastner Salzburg

    Hello

    Check to see if that helps

    https://docs.Oracle.com/CD/E17781_01/install.112/e18803/TOC.htm#XEINW127

    Kind regards

    Jari

Maybe you are looking for