Accesing file in another package

I am using Netbeans 6.0 and I am currently accessing another text file in another package called "files" like so:
br = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("\\files\\"+filename)));This works fine and finds the files when I run the code but it doesn't find the files when I build the jar file and run it separately.
Any idea what could be happening?

In a JAR, paths that start with a slash like:
getResourceAsStream("/a/b/c/d.txt")Start at the "root" of the jar. For this to find the resource, verify that /a/b/c/d.txt is in the JAR.

Similar Messages

  • Writing to file within another package

    Hi all, I had a search in the forums, but I couldn't find what I was looking for.
    I have what I consider to be good code organised into packages that make sense, but for some reason, I cannot programmatically save Files to where I want to.
    If I create them manually, they read fine, (with
    File xmlFile = new File(this.getClass().getClassLoader().
            getResource("data/records.xml").getFile());
    SAXBuilder builder = new SAXBuilder();
    Document xml = builder.build(xmlFile);).
    So now I want to create this file programatically.
    The code I have is
    // Make a new file
    File xmlFile = new File("data/" + p.getName() + "deck.xml");
    xmlFile.createNewFile();But that gives (probably unsuprisingly)
    java.io.IOException: The system cannot find the path specified
         at java.io.WinNTFileSystem.createFileExclusively(Native Method)
         at java.io.File.createNewFile(File.java:883)
         at gamepackage.PlayerDeck.updateDeck(PlayerDeck.java:99)When I create a file in the default package (probably frowned upon) with
    // Try create file in default package
    File xmlFile = new File(p.getName() + "deck.xml");
    xmlFile.createNewFile();It works as expected (except my file is in the default package).
    So, it must be a package problem. I have tried messing around with mkdir(), but that creates Files in directories called "data" rather than my existing package "data" (which confuses my little soul, because I thought packages were treated as directories (see JAR files etc)), and I have tried messing around with URIs and URLs, to little avail. Also, ClassLoaders such as
    File xmlFile = new File(this.getClass().getClassLoader().
                      getResource("data/" + p.getName() + "deck.xml").getFile());wont work, because I need to create the file before I can call .getFile(); but I need the File to call createNewFile() on.
    Please can you point me in the right direction? Many thanks in advance.

    Hemmels wrote:
    I've been playing CS and BF2142 and went for a jog, and we're into double figure views It's not a bad question, and you presented your problem well, it's just... well it isn't done this way. Packages are really intended to solve +this* problem. But the organization (and unique identifying) of source files problem.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How can we call a class file of one package for class file of another

    How can we call a class file of one package from class file of another package and both packages exist in a same folder

    How can we call a class file of one package from
    class file of another package and both packages exist
    in a same folder
    Luckily they don't so it's really not a problem after all.

  • A package that "patches" another package

    I'd like to make a PKGBUILD for usb-rndis-lite v0.11. Usb-rndis-lite contains files that should replace some files from 'kernel26' package. Is it right when one package replaces files from another package? If so, what is the right way to do that?
    The point is that USB RNDIS driver, included in current 2.6.26 kernel is either outdated or buggy, so sometimes it needs to be replaced by SynCE's usb-rndis-lite. Unfortunately that driver is a part of kernel26 package and cannot be separately removed.

    Mr.Cat wrote:Nothing would prevent me from doing this, but that would be the "wrong way", I suppose. And you've mentioned one of the reasons - possible problems with correct package removal. Another problem I see - is that when kernel26 is updated - my package's files would be owerwritten.
    Exactly. Pretty ugly solution, although possible. In the install script, you can specify an uninstall function, so theoretically you can backup the original driver on install, and restore on uninstall, with a check if it hasn't been updated meanwhile.
    UPD:
    bender02 wrote:There's a special directory where you can put your patched/updated version of a driver, and then modprobe/insmod would load that new version, when the driver is requested.
    Thanks, worked for me.
    UPD:
    I've submitted a PKGBUILD for rndis-usb-lite (v0.11) to unsupported: http://aur.archlinux.org/packages.php?ID=20336.
    I'm glad it worked.

  • How to embed and launch ipa file from another ipa package created using Air for iOS

    Hi Guys,
    Anybody out there knowing how to embed and launch ipa file from another ipa package created using Air for iOS ?
    I am having 1 ipa file created using Xcode, Now i need to include that file in my ipa Package which is created using Flash CS 5.5 and Air for iOS. Also i need to know how to open my 1st ipa file from AS3 ?
    Thanks,

    Hi Sir,
    Thanks for your reply.
    But in that case user need to download 2 applications right. I need user to download my parent application created using Flash and that package contain one more ipa created using Xcode, so from my parent app only user should able to open my 2nd app. Is there any way to do that?
    Ps:  I am not talking about in-app but 2 individual apps inside one package.

  • How to copy file to another server from database using FTP in oracle

    How to copy file to another server from database using FTP in oracle.
    Please do the needfaul.

    Billy  Verreynne  wrote:
    BluShadow wrote:
    Not to mention that some FTP servers can return more than one return message per operation whereas others may return one message for the same operation.I had the problem using the LIST command to determine if a file exists on the server. Cannot be determined via the FTP server's return code. Which means parsing and checking the text response from the server to the command. And this vary from server to server.
    But the basics were quite easy to code. The entire package is 500 lines, includes comments and blank lines for formatting, and supports the basic FTP client command set. Not really a complex piece of software to write - but I found that many developers seem to think that writing network socket software is complex. Not really the case...Mine's a big larger, but incorporates functionality similar to what Chris provided in his, such as being able to use SQL to query a remote file using pipelined functions, or functionality to write the results of a query directly to a remove file.
    :)

  • I want to send a value from JSP file to another JSP file without..

    I want to send a value from one.JSP file to another two.JSP file without to show the content HTML of the one.JSP in two.JSP (with include), only take the values processed in a Bean :
    ===================
    Bean
    package pck;
    import java.io.*;
    public class yyyy {
         public String getXxx() {    
              return cccc;
    ========================
    one.JSP
    <jsp:useBean id="idBean" class="pck.yyyy" scope="??"/>
    <%idBean.setXxx(ccc);%>
    ========================
    two.JSP
    <%@ include file="one.jsp"%>
    <%=idBean.getXxx()%>
    but without to show the content HTML of one.JSP in two.JSP.
    Can someone help me?, please.

    Why don't just put the common code in a separate file and include it in both. i.e. the code that is in one.jsp that is needed by two.jsp could be put in a common file and included in both pages, thus the HTML is separated off. If this will not work, set a boolean value in two.jsp that can be used by one.jsp to decide if the HTML should be displayed or not.
    Steve

  • How to remove files in Miscellaneous Packages

    Hello,
    I recently moved from another IDE to JDeveloper 10g. In doing so, I imported an existing J2ee application.
    All packages were imported, however, all files in all packages were also added to the Miscellaneous Packages node as well, which causes compilation errors. Can you please advide me on how to resolve this problem?
    Cheers,
    Rudi

    I just experienced the same problem. The details this time were:
    Note: My goal was to move a project onto a stand alone network. The only way to move files is via CD/DVD.
    1. Tar'd up development directory on Linux machine.
    2. Burned to CD and transfered to Solaris target.
    3. Untar'd to /usr/local/projects/... trying to be slick and put it in a shareable place...
    4. created a symbolic link from /usr/local/projects to /home/user/projects
    5. Using JDev 10.1.2.1 opened /home/user/projects/MyProject/MyProject.jws
    6. Looking inside the projects referenced by my workspace, found that most, but not all files were in "Miscellaneous Files". Also, compiling generated lots of errors about having duplicate class files.
    7. After several failed attempts, tried opening as /usr/local/projects/MyProject/MyProject.jws
    Success. Everything worked peachy.
    So, why does the symbolic link seem to throw things off? For now, I just won't do that anymore...

  • USage of import java.util.* & using another package

    When we use import java.util.*; from where does JAVA take the class that are related to util, when I did search for "util" in my machine, I got about 50 results for folders named util and also some where in a folder called "java" when I opened it it did not have the classes, that I was expecting. So I am not clear where does it get the class files from. This is not only for this but for any import commands like import java.io.*;
    When we get another package or source code which was written in java and want to use it in our code where do we have keep the files ? eg. i have the java code that i m writing in c:\java then do I put all the downloaded related files in that folder and then run the code ? or i keep a folder inside java folder and then import them into my code ?
    please do advice.
    Thanks in advance.

    When we use import java.util.*; from where does JAVA
    take the class that are related to util,It means when you use a classname in your code, and that classname is neither in the same package as the class you're writing, nor imported specifically by classname, that it will search for it.
    Where it searches is every folder called util whose parent folder is called java which in turn is at the root level of one of the classpath elements. That is, if classpath contains "A" and "B", and you refer to a class called "Foo", then it will look for "A/java/util/Foo.class" and "B/java/util/Foo.class".
    search for "util" in my machine, I got about 50
    results for folders named util and also some where in
    a folder called "java" when I opened it it did not
    have the classes, that I was expecting. So I am not
    clear where does it get the class files from. This is
    not only for this but for any import commands like
    import java.io.*; All the java.* and javax.* and whatever else it part of the core API is in rt.jar, which lives inside the Java distribution. Classpath elements can be directories or jar files or zip files.

  • SSIS 2008 R2 - Export data to Flat File in another server

    Hello Everybody,
    I'm trying to export data from a table in database server to flat file in another server, however it is happening the error Access Denied. I'm using SQL Server Integration Service 2008 R2 to do this.
    I've checked all the ways that's happening could the level of security and could not resolve. 
    Please could someone tell me what I'm missing in this case? 
    Following error log:
    SSIS package "AtualizarDados.dtsx" starting.
    Information: 0x4004300A at Gerar arquivo, SSIS.Pipeline: Validation phase is beginning.
    Information: 0x40043006 at Gerar arquivo, SSIS.Pipeline: Prepare for Execute phase is beginning.
    Information: 0x40043007 at Gerar arquivo, SSIS.Pipeline: Pre-Execute phase is beginning.
    Information: 0x402090DC at Gerar arquivo, Geração de Arquivo [63]: The processing of file "\\targetserver\Export_File\Export_File.txt" has started.
    Warning: 0x80070005 at Gerar arquivo, Geração de Arquivo [63]: Access is denied.
    Error: 0xC020200E at Gerar arquivo, Geração de Arquivo [63]: Cannot open the datafile "\\targetserver\Export_File\Export_File.txt".
    Error: 0xC004701A at Gerar arquivo, SSIS.Pipeline: component "Geração de Arquivo" (63) failed the pre-execute phase and returned error code 0xC020200E.
    Information: 0x40043008 at Gerar arquivo, SSIS.Pipeline: Post Execute phase is beginning.
    Information: 0x402090DD at Gerar arquivo para DMZ, Geração de Arquivo [63]: The processing of file "\\targetserver\Export_File\Export_File.txt" has ended.
    Information: 0x4004300B at Gerar arquivo, SSIS.Pipeline: "component "Geração de Arquivo" (63)" wrote 0 rows.
    Information: 0x40043009 at Gerar arquivo, SSIS.Pipeline: Cleanup phase is beginning.
    Task failed: Gerar arquivo
    SSIS package "AtualizarDados.dtsx" finished: Success.
    Regards,
    Antonio Estima

    I got after using domain user. 
    Thanks to all

  • HELP: Copying layers from one file to another to keep structure not possible??!!!

    Hi guys,
    I have a curious question. Sounds a bit silly and highly disappointed if Illustrator is actually not capable of doing this. Hopefully I have missed something.
    I have an AI doc that has grown so large that saving it now is a major effort so trying to break out sections into multiple AI files. Allot of users will be working on these files so it is imperative that all the Artboard elements are clearly organized in the appropriate folders (layers). Im trying to simply copy and paste a layer that has multiple layers beneath and within those more layers to another empty AI file. Everything copies correctly and in place however it dumps all the elements into a single massive layer in the new file. If I go into the Layer Palette menu and check on Paste Remembers Layers it does a better job at keeping some of the structure but it still doesnt copy exactly how the structure was in the Master document.
    Please tell me Im doing something wrong. I cant believe that you cant simply drag and drop a parent layer from one file to another while maintaining its structure! Exactly like in Photoshop - copying a folder from one file to another is simply as easy as dragging and dropping ...is this same methodology not available with Illustrator? I always assumed the layer and folder concept between these two packages were somewhat interchangeable.
    Thanks for any help, comments, or suggestions
    Nick.

    Hi All,
    After much trial and error trying to locate where the problem was it ended up being the guide objects. If you have the guides set to lock and attempt to copy out any layer that a guide is sitting in the resulting copy/paste will break apart that layer structure in the destination file. Simply setting the guides unlock allows everything to translate correctly.
    You guys may have known about it already but I learnt a little something in the process. Thanks to all for your suggestions!
    Cheers

  • How to use loadjava tool to regard file in other packages/JARs?

    How do I have to set the options for the loadjava tool when I have a Java class that uses classes of another package/JAR (which I have developed by myself). I thought it was just to create a JAR containing my Java class as well as the JARs containing the other packages/classes being imported in my Java class. and then:
    loadjava -u user/passwd@hostname:1521:xxx -v -r C:\Temp\MyJAR.jar
    but I always get
    cannot find symbol    :    class MissingClass

    This is the wrong forum!
    1. Repost the question in the Database JVM forum
    Java in the Oracle Database
    2. Edit this thread and post the link to the new one and direct people to follow up there
    3. Mark this thread ANSWERED so people will follow up in the other forum.
    When you post there provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION) and review Chapter 11 Schema Objects and Oracle JVM Utilities in the Java Developers Guide
    http://docs.oracle.com/cd/B28359_01/java.111/b31225/cheleven.htm#CACFHDJE
    see '-recursivejars' in the Argument Summary section.
    >
    -recursivejars
    Normally, if the loadjava tool encounters an entry in a JAR with a .jar extension, it will load the entry as a resource. If this option is specified, then the loadjava tool will process contained JAR files as if they were top-level JAR files. That is, it will read their entries and load classes, sources, and resources.

  • Accessing a Static Array in one CAP file from another CAP in same project

    Hi all,
    I have been developing a banking application on JavaCard. So the size of the applet has grown size able and have now split the file to multiple CAP files. I have been using NXP JCOP plugin in Eclipse for development. Below are the steps done
    a.) I have created multiple packages under the same project where one project has all the variable which are public static final and don't reference any other class. Also this package does not extend Applet. So it finally generates to a CAP file.
    b.) Another package which imports the above package and also extend Applet is the one which has all the UI and logic related to the project. The applet uses the static array defined in the another package to show the menu on phone.
    Now the problem is that when the code come to point for fetching the menu data, i have some thing like menu.length . But when the code comes to this point in debugger i get a
    +6F 00    Status: No precise diagnosis.+
    To cross check i put a watch on the menu variable and found that it has all the data required for showing the menu (which is of 32 byes). So now i am perplexed on why this length is giving this problem. Am i doing some thing wrong. Below is the Snip of the larger code
    This code is the package which has all the constants..
    package constantsPack;
    import javacard.framework.APDU;
    import javacard.framework.ISO7816;
    import javacard.framework.JCSystem;
    import javacard.framework.Util;
    public class ConstantsApplet {
    //menu array decleration
    public static final byte[] MAIN_SETUP_MENU = {
                       (byte) 0x81,  ConstantsApplet.CMD_DTL_LENGTH, ConstantsApplet.CMD_NUMBER, ConstantsApplet.MAIN_CMD_SET_UP_MENU, (byte) 0x00,
                       (byte) 0x82, (byte) 0x02, ConstantsApplet.DEVICEID_SIM, ConstantsApplet.DEVICEID_ME,
                       (byte) 0x85, (byte) 0x08 ,'A','B', 'C',' ','A','p','p','s',
                       (byte) 0x8F, (byte) 0x0D, ConstantsApplet.SB_MENU, 'A','b','c','d','e','f','g',' ','B','a','n','k',
    // other constants.
    }This is the package which has the applet and which uses the variables of the above package
    package myPkgLib;
    import constantsPack.*;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    import javacard.framework.ISO7816;
    import javacard.framework.ISOException;
    import javacard.framework.OwnerPIN;
    import javacard.framework.Util;
    import javacard.framework.JCSystem;
    public class myApplet extends Applet{
    // other code
    fetch(ConstantsApplet.MAIN_SETUP_MENU.length);
    }Any help regarding this would be very helpful...
    Regards
    Prakash
    Edited by: prakash on Apr 18, 2012 11:57 PM

    Hi lexdabear,
    I tried putting a function inside the library package where the static array is present, but the results are the same... Also by try catch . what exception you want to catch... i see Exception has just .equal function... Tried with ExternalException also but does not seem to enter it..
    Attaching the source code compilable in eclipse below ..
    package constantsPack;
    public class ConstantsApplet {
         public static final byte[] MAIN_SETUP_MENU = {
              (byte) 0x81, (byte) 0x03, (byte) 0x01, (byte) 0x25, (byte) 0x00,
              (byte) 0x82, (byte) 0x02, (byte) 0x81, (byte) 0x82,
              (byte) 0x85, (byte) 0x08 ,'A','B', 'C',' ','A','p','p','s',
              (byte) 0x8F, (byte) 0x0D,  0x0F, 't','e','s','t','a','p','p',' ','B','a','n','k',
              public ConstantsApplet ()
    }The applet code where the above static array is used..
    package smilePkgLib;
    import constantsPack.*;
    import javacard.framework.APDU;
    import javacard.framework.Applet;
    import javacard.framework.ISOException;
    import javacard.framework.Util;
    public class BLApplet extends Applet{
         short fetchcode =0;
         public static void install(byte[] bArray, short bOffset, byte bLength) {
              // GP-compliant JavaCard applet registration
              new smilePkgLib.BLApplet().register(bArray,
                        (short) (bOffset + 1), bArray[bOffset]);
         private BLApplet(){
              // put init code
          * The main method.
         public void process(APDU apdu) throws ISOException {
              if (selectingApplet()) {
                   return;
              byte choosenMenuItem = 0;
              byte[] buf = apdu.getBuffer();
              byte bytesRead =(byte)(apdu.setIncomingAndReceive());
              fetchList(ConstantsApplet.MAIN_SETUP_MENU , (byte)0x00);
         private void fetchList(byte[] list, byte command){
              shouldFetch(list);
          * Overloaded method to fetch the MENUs only.     
          * @param menu
         private void shouldFetch(byte[] menu) {
              shouldFetch((byte)menu.length);
         private void shouldFetch(byte len) {
                   fetchcode = Util.makeShort((byte) 0x91, (byte) (len));          
    }The JCOP script to run the above project
    /select |DefaultApplet
    # Terminal Profile
    /send A0100000133B67FF7F1F020F0B4100000000869804000000 Have the eclipse loadable project but dont know how to put here...
    Regards
    prakash.

  • How to compile and run a .java file from another java program

    hello,
    can any one tell me how to compile and run a *.java* file from another java program which is not in same directory?

    Well a smarter way of implementing this is by using a solution provided by Java Itself.
    If you are using J2SE 6.0+ there is an in built solution provided along with JDK itself and inorder to go ahead with solution the below are set of API which you;d be using it for compiling Java Programs (Files)
    http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html
    How do i do that ??
    Check out the below articles which would help you of how to do that
    http://www.ibm.com/developerworks/java/library/j-jcomp/index.html
    http://www.javabeat.net/javabeat/java6/articles/java_6_0_compiler_api_1.php
    http://books.google.com/books?id=WVbpv8SQpkEC&pg=PA155&lpg=PA155&dq=%22javax+tools%22+compiling+java+file&source=web&ots=XOt0siYe-f&sig=HH27ovuwvJgklIf8omTykUmy-eM
    Now once we are done with compilation.In order to run a Specific class all you ought to do is create an object and its specific methods of a specified class included in the CLASSPATH which you can manage it easily by usage little bit reflections.
    Hope that might help :)
    REGARDS,
    RaHuL

  • Can I create another package for another module?

    Hi,
    I am doing a project in NetBeans.
    I used a JFrame with Menu and a JDesktopPane with five JInternalFrames for my I module.Now I first module is finished.
    My designing and coding are in Package Javaapp1.
    For II module I have to create another JDesktopPane with five jInternalFrames.
    If I use the same Javaapp1 package for II Module my coding is very large and difficult to trace.
    can I create another package Javaapp2 for II module and import
    in my first package?
    if it is possible? please give me few lines about this.
    Thank you so much.
    Meena.

    Hi,
    Thank you so much for your reply.
    I understand what you mean.
    I am developing only one project not two many.
    But I have four modules in my project.So I try to the concept of package.
    In NetBeans I first create one project named Javaapp1.
    It automatically comes under the name Package Javaapp.
    In this I finished my first module.
    Now I want to develop second module.To avoid confusion in coding I need to create second module in different package.
    So I create another project Javaapp2.It comes under the name
    Package Javaapp2.I develop II module here.
    Then I try to import Javaapp2 in Javaapp1.I got the error "Package Javaapp1 doesnot exist".Thenonly i add needed jar file(Javaapp2.jar) into my project.Now there is no error.
    You told me that "The Above Approch is for when we create more than one project and take something from one to other".
    But I donot know how can I create another package without creating another project and without including the jaf files.
    I donot know is there any way to do.
    I am also have a look at netBeans.org.
    Can I continue with this?
    will you please comment on my lines.That should be useful to me to get a idea.
    Thank you so much.
    Meena.

Maybe you are looking for

  • How to create a pull down table ?

    At first i am sorry for my bad English. Now i want to code an application. I want to create a button, when user click on it, a table or something pull down like this picture : http://i4.photobucket.com/albums/y142/lanhhuyet/untitled-7.jpg . I don't k

  • IDVD slideshows crash Mac DVD Player

    So, I created my movie in iMovie, exported it to iDVD 8, and then I added two slideshows. One slideshow has 110 pictures and the other slideshow has about 12 pictures. Both slideshows play perfectly in iDVD preview mode and on my Panasonic DVD player

  • J6480 part of page prints too light

    A friend of mine has an hp office jet all in one printer model j6480 that is giving her problems. When she prints a page, the top half looks good, but the bottom prints too light. When she prints another page right after that, the same problem occurs

  • TS1718 itunes 12.0.1.26 not playing downloaded movies black screen Windows 7

    I am using iTunes for windows and the recently bought 2 movies, the trailer worked fine , but after download the itunes is not playing the VDO files, its simple black screen. Can someone please help? No wonder why I dont use Apple. they dont even giv

  • Document Metrics in KM

    Hi - We would like to be able to generate reports that give us KM metrics such as 1) How many documents exist in KM?  2) When was the last time a document was checked out / modified? I noticed in another thread that you can check the DB tables wcm_su