Results 1 to 4 of 4
  1. #1
    Mekonom is offline Member
    Join Date
    Nov 2009
    Posts
    71
    Rep Power
    0

    Default adding resources to jar file

    Hi all . I have a little problem but I cant figure out it . I want to add to my project some resources like music, video or simply txt file .But when i run my code whit compiler it works normal ands shows that path file is normal .but when i run Jar file in my computer or on another compter it doesnt see thoose resources..

    for example I am addin txt file to project in src folder in package where my.java files. and in path i am using like src/packagename/file.txt. it works when i am compiling with compiler NetBeans. but when I run jar file in dist folder it doesnt see this .txt file.Where am I wrong?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Resources in Jar files are not files but resources, so you may need to change the way that you are referencing them.

  3. #3
    Mekonom is offline Member
    Join Date
    Nov 2009
    Posts
    71
    Rep Power
    0

    Default

    but after that when i run on compiler it doesnt see..

  4. #4
    Mekonom is offline Member
    Join Date
    Nov 2009
    Posts
    71
    Rep Power
    0

    Default

    I solved my problem. I was using simply File file=new File("/name.txt")
    But every body recommed that
    InputStream inputStream = nameclass.class.getResourceAsStream("name.txt");

    and it works :)

Similar Threads

  1. adding printf to system.in file
    By bettyhagan in forum New To Java
    Replies: 2
    Last Post: 12-21-2009, 12:11 PM
  2. Access to resources inside jar file
    By aleks.farrier in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 04-15-2009, 02:29 PM
  3. Adding a new class to a jar file
    By Raul Menendez in forum New To Java
    Replies: 2
    Last Post: 08-21-2008, 05:52 PM
  4. Adding file names(Help!!)
    By Gambit17 in forum New To Java
    Replies: 4
    Last Post: 11-09-2007, 08:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •