How to use txt files in jar file

Hi all
I just made a program that uses a text file, but I havent managed to work it correctly, program runs without jar correctly, but when I packaged all files into a jar, it couldnt find txt file, so I can only run it when I create another text file outside of jar.
How can I solve this??

I used this:
Scanner fileScan = new Scanner (new file
("Words.txt"));
but when I make a jar file, it doesnt find the txt
file inside a jar,
do I need to specify path or something?I have already told you that you shouldn't use new File(..) you should use getResourceAsStream(String name) to get an InputStream to the file.
Kaj

Similar Messages

  • How to use Stylesheets packaged in JAR file

    Hi,
    I would like to package XSL files in a JAR. The stylesheet may import other XSL files. For example:
    <xsl:import href="demos.xsl">
    <xsl:import href="table.xsl">
    where the original stylesheet and the imported stylesheets (demos.xsl and table.xsl) are all located in this package: com.company.xsl
    Is there a way for the transformers to retrieve the files from the JAR?
    Possibly another complication is that this JAR file is loaded at runtime.
    Any suggestions would be of great help. Thanks!

    Thanks that worked.
    However, is it possible to use a relative path? Right now it only works if the absolute path is used:
    <xsl:import href="jar:file:///c:/applications/bin/myjar.jar!/com/company/xsl/table.xsl" />
    It would be nice if this worked instead:
    <xsl:import href="jar:file:///./bin/myjar.jar!/com/company/xsl/table.xsl" />

  • How to use methods from a JAR file inside my springcontext (Oracle fusion 12c) class file?

    Dear Friends,
    I have a jar file, which has executed classes and methods in it. I want to make use of these methods inside my springcontext piece of code.
    Can someone please share an example  of how to write spingcontext code which is accessing classes/methods from  JAR files along with the any setup?
    Thanks,

    I have found the answer... as described in:
    http://java.sun.com/javase/6/docs/technotes/guides/lang/resources.html
    the problem was that the properties are loaded with the getResource & getResourceAsStream methods and I didn't know that one. I thought that is was loaded through findClass because I saw the property files trying to be loaded through findClass.
    The truth is that it tries to load with the getRessources methods and if it fails tries with the findClass/loadClass.
    To Fix the problem, I have simply overriden the getRessourceAsStream to do my magic and that was it.
    Thanks

  • How to use external libraries and JAR files with OpenScript

    Hello.
    I am trying to include ApachePOI, JODATime, and Javamail in my scripts to handle different aspects of our automated performance tests.
    I followed the documentation for Eclipse to be allowed to utilize these external libraries, however, when I attempt to run my tests the classes and methods that are being imported, show up with errors saying that they do not exist.
    I think perhaps that I am using them incorrectly. I cannot see them as script assets, package assets, or project assets using the properties for these items. An error pops up and says those screens are not displaying correctly or display incorrect information.
    If anyone can provide guidance on using these items, that would be great. Right now I'm trying to include them as "previously exported scripts" but I'm not sure that method will work.
    Any advice is appreciated.
    Thanks.
    --tiff                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Tiff
    For OpenScript 9.* there is an out of the box solution for that, all you need to do in OpenScript go to:
    Script -> Script Properties -> Script Assets -> Add -> jar File ....
    And that is it.
    Alex

  • How to list files from .jar file in applet?

    I have created applet and export all files to .jar file.
    I use File.list() method in applet to list files from one directory and that works ok but if I try to do that from web browser it sends exception AccessDenied meaning that File.list() isn't allowed in browser.
    I know what's the problem but I don't know how to solve it.
    What I want is to read from directory list of files.
    Help anyone?

    I will post here my code so that can be seen what I want to do:
    import java.awt.BorderLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URLClassLoader;
    import java.nio.charset.Charset;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JTextPane;
    public class test extends JApplet {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JTextPane jTextPane = null;
          * This is the xxx default constructor
         public test() {
              super();
          * This method initializes this
          * @return void
         public void init() {
              this.setSize(449, 317);
              this.setContentPane(getJContentPane());
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.add(getJTextPane(), BorderLayout.CENTER);
              return jContentPane;
          * This method initializes jTextPane     
          * @return javax.swing.JTextPane     
         private JTextPane getJTextPane() {
              if (jTextPane == null) {
                   jTextPane = new JTextPane();
              return jTextPane;
         public void start(){
              File fileDir= new File("somedirectory");
              String strFiles[]= fileDir.list();
              String a="";
              for(int i =0;i<strFiles.length;i++){
                   a=a+strFiles;
              this.jTextPane.setText(a);
    Method init() is irelevant, it just adds JTextPane in applet.
    Method start() is relevant, it runs normaly when started from Eclipse but from browser it sends exception AccessDenied.

  • Problem with JSP using bean packaged in jar file

    Hi,
              I am trying to use a java bean in a jsp file. The java bean is packaged
              into a jar file. I am getting class not found compilation error. If the
              bean remains to be a seperated class file, everything work well.
              Does anyone know how I can use bean in a jar file within jsp , i.e. to
              allow the bean to be found during compilation ?
              Thanks,
              Terence.
              [email protected]
              

    Jacek,
              Thanks for replying.
              My JSP's are just files in my document root . However, I found a solution to
              my
              problem. That is to have the jar file defined in my weblogic.class.path. I may
              have missed some files in my original jar file which causes my problem.
              Mayby I should package everything into a web application for deployment. That
              will be my next step.
              Thanks anyway.
              Terence.
              Jacek Laskowski wrote:
              > Terence Lai wrote:
              > >
              > > Hi,
              > >
              > > I am trying to use a java bean in a jsp file. The java bean is packaged
              > > into a jar file. I am getting class not found compilation error. If the
              > > bean remains to be a seperated class file, everything work well.
              >
              > How do you use the JSP file ? Is it a part of web application ? If so,
              > the bean jar package should be located in WEB-INF/lib directory. It's
              > also recommended to put the bean class into a package, so it's not in
              > 'unnamed' package, and <jsp:useBean> can find it.
              >
              > >
              > > Does anyone know how I can use bean in a jar file within jsp , i.e. to
              > > allow the bean to be found during compilation ?
              >
              > see above.
              >
              > > Terence.
              >
              > Jacek Laskowski
              > HP Consulting
              

  • How to handle 2 or more .jar files with an applet

    Hey out there
    I have created an ftpClient application that uses "jakarta ftpClient". It works fine as an JFrame application � But when I converted the Application into an JApplet I get the following Exception:
    java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
    I have bundled the main application into a .jar file (Application,jar). But I don't know how to handle the 2 jakarta .jar files with my JApplet??
    I Tried to append the 2 jakarta .jar files to the Application,jar with the following code:
    jar cvf Application.jar 1.class 2.class�. commons-net-1.4.1.jar jakarta-oro-2.0.8.jar
    But with the same result / Exception (I have signed the Jar file!)
    Can anyone help me

    Hi i have a question with your application can you down- or upload more files at the same time? Because i'm having problems with my ftp application.
    Here is the link with my problem maybe you can help me. I will be very pleased when you can help me.
    http://forum.java.sun.com/thread.jspa?threadID=5162042&tstart=0
    Thx
    Satanduvel

  • How do I deploy an external JAR file

    Hello,
    How do I deploy an external JAR file?
    I am grateful for every hint.

    Hi Manuel,
      If you read my blog mentioned in the beginning of the thread, you will note that such solution is not supported in our engine due to number of reasons.
      Please, read the blog and use application library shared among these two applications. You will achieve the same effect. Please note that the using application will need run and deploy-time dependencies to the shared library.
      You should not add files to any of the folders manually or manipulate engine's classpath in such situations.
    Best Regards,
    Georgi

  • How can I get a single jar file with NetBeans?

    How can I get a single jar file with NetBeans?
    When I create the project I get these files:
    dist/lib/libreria1.jar
    dist/lib/libreria2.jar
    dist/software.jar
    The libraries that have been imported to create the project are in separate folders:
    libreria1/libreria1.jar
    libreria2/libreria2.jar
    libreria1, libreria2, dist folders are all located inside the project folder.
    I added the following code to the build.xml:
    <target name="-post-jar">
    <jar jarfile="dist/software.jar">
    <zipfileset src="${dist.jar}" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria1.jar" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria2.jar" excludes="META-INF/*" />
    <manifest>
    <attribute name="Main-Class" value="pacco.classeprincipale"/>
    </manifest>
    </jar>
    </target>
    Of course there is also the project folder:
    src/pacco/classeprincipale.form
    src/pacco/classeprincipale.java
    Can you tell me what is wrong? The error message I get is as follows:
    C:...\build.xml:75: Problem creating jar: archive is not a ZIP archive BUILD FAILED (total time: 2 seconds)

    This is not a NetBeans forum, it is a JDeveloper forum. You might want to try http://forums.netbeans.org/. I also saw your other question - try looking in the New to Java forum: New To Java

  • How to install a Application in *.jar file format?

    How to install a Application in *.jar file format?
    I have taken the *.jar file into the device into media folder. but device is not recognizing the file format
    could some one plz provide some suggestion to proceed with this?
    Thanks
    Mohamed Javeed

    I'm having the same problem.  I've put .jar into the 'system' folder but that doesn't seem to make the program work neverless see it on my device.  Help.

  • How to use utl_ftp package to transfer files from one system to another

    Hi all,
    How to use utl_ftp package to transfer files from one system to another using plsql procedure .
    I failed to find the appropriate document ,kindly help me .
    Thanks,
    P Prakash

    prakash wrote:
    I am sorry tell you, this blog is not enough to for me.It's not a blog, it's Chris' website where you download the package from. Once you download the package and unrar it, then the package spec gives instructions (and I think there's instructions on how to install it too).
    Kindly let me know if there is any oracle documentation for this .It's not an Oracle created package, it was created by Chris. It's based around the UTL_TCP package if you really want to get into the nitty gritty of how it works, but I don't think you do.

  • How to Include more than one jar files

    My application uses more than one jar files. And all the jar files i am using are signed. when i include the jar files, i am including them in the resources section of the ".jnlp" file . The section of code looks like this:
    <resources>
    <jar href="utestfw.jar" main="true" download="eager"/>
    <jar href="crimson.jar"/>
    <jar href="jaxp.jar"/>
    </resources>
    <application-desc main-class="utestfw.ObjectBrowser"/>
    The deployment of the application is successful. The jar file - "utestfw.jar" contains the application main class when the application is launched it works, but when i choose the feature which involves the classes of either "crimson.jar" or "jaxp.jar" , the application terminates and the webstart console and the application is closed automatically. Am i wrong in adding the jar files? what is the way to add more than one jar files to the ".jnlp" file.
    Can anyone please help me?
    -Aparna

    I'll post u the jnlp file which i am using. To sign all the jars i've used the same alias ( a self signed certificate using keytool and jarsigner).Here is the jnlp file:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="0.2 1.0"
    codebase="http://127.0.0.1:8080/healthdec"
    href="testTool.jnlp">
    <information>
    <title>Unit Test Manager </title>
    <vendor>Sun Microsystems, Inc.</vendor>
    <description>A minimalist drawing application along the lines of Illustrator</description>
    <icon href="images/testing.gif"/>
    <offline-allowed/>
    </information>
    <resources>
    <j2se version="1.3+ 1.2+"/>
    <jar href="utestfw.jar" main="true" download="eager"/>
    <jar href="crimson.jar" main="false" download="eager"/>
    <jar href="jaxp.jar" main="false" download="eager"/>
    </resources>
    <application-desc main-class="utestfw.ObjectBrowser"/>
    <security>
    <all-permissions/>
    </security>
    </jnlp>
    Can u please look at the above code and suggest me where i am wrong. Thanks.
    -Regards
    Aparna

  • Since downloading firefoz 4, everytime I make a browser search I get a second page with :"Firefox can't find the file at jar:file://how can I solve the problem. Kindly reply to :ramses1@videotron.ca

    Question
    firefox 4, when I make a browser search I get a second page:"Firefox can't find the file at jar:file:///D:/Program Files/Mozilla Firefox/omni.jar!/chrome/browser/content/browser/<url></url>", how can I solve the problem.

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]

  • How to get the class file of jar file

    hello all,
    is there any way to get the class file of jar file,as we have when we compile a java file we get class file
    same do we have any option to get the class file of jar file

    A jar file is a zip archive, so you can uznip it or extract the contents with the command "jar" - if it is what you need.

  • How to run .class file and .jar file in jdev9i

    I want to run .class file and .jar file in jdev9i,what should I do?
    Also,I want to generate .class file and .jar file in jdev9i,what should i do?

    Add the .class file containing the public static void main(...) method to the project by clicking on the + toolbar button in the navigator, open the project properties and properly set the additional classpath then right click on the .class in the navigator and say run. It should work, I've just tried it.
    Doesn't work for a .jar yet, in JDeveloper 9.0.3 it works both for .class and .jar
    Michel

  • When searching, I get this message: Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/chrome/en-US/locale/browser-region/region.propertiesproblems.

    when I enter a word in the search window (the one with the curved arrow at the end), I get this message:
    Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/chrome/en-US/locale/browser-region/region.propertiesproblems.

    Try the Firefox SafeMode to see how it works there. <br />
    ''A troubleshooting mode, which disables most Add-ons.'' <br />
    ''(If you're not using it, switch to the Default Theme.)''
    * You can open the Firefox 4/5/6/7 SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut.
    * Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''Don't select anything right now, just use "Continue in SafeMode."''
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut (without the Shft key) to open it again.''
    If it is good in the Firefox SafeMode, your problem is probably caused by an extension, and you need to figure out which one. <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes

Maybe you are looking for

  • Error in deploying the application in WL9.2 mp1

    Hi, I am using WL 9.2.1 and my OS is Windows XP. My build is coming fine and when i start my server after adding the project to it. It shows the following errors while publishing. Can anybody help me. I am also not able to deploye the application fro

  • Hp laserjet 100 color mfp m175nw not working anymore – MAC OSX YOSEMITE

    After installing the YOSEMITE update my hp laserjet 100 color mfp m175nw not printing anymore. Connection is USB. And OSX Drivers are all up-to-dae. Also i heared similar problems with other printers than HP. Any help? Thanks alot.

  • Differences between assets and G/L accts in the balance carried forward

    Hi Folks, I am having problem with this: Differences occurred in the balance carried forward when comparing asset summary records and G/L accounts. Thanks,

  • Keycode missing in Crystal Reports Basic for Visual Studio 2008

    I just upgraded from Visual Studio 2005 Professional to Visual Studio 2008 Professional (with SP1 installed also).  Crystal Reports Basic for Visual Studio 2008 is listed as installed under the VS Help dialog, but no key code is shown.  And when I at

  • Quicktime to clips

    I'm using FCPro. I was given several long Quicktime files that have to be cut up into clips and sorted out. I imported them into my project and started to mark them and drag them back into the bin area. It works great but I'm having trouble re-naming