Results 1 to 8 of 8

Thread: all java files in one

  1. #1
    Member
    Join Date
    Jan 2010
    Location
    suffolk
    Posts
    113
    Thanks
    6
    Thanked
    9 times in 9 posts
    • richy19's system
      • Motherboard:
      • Dell e520
      • CPU:
      • intel e4300 OC 2.4ghz
      • Memory:
      • 2gb pc5200
      • Storage:
      • 550gb
      • Graphics card(s):
      • sapphire hd 4650
      • PSU:
      • Dell
      • Case:
      • Dell e520
      • Operating System:
      • Windows 7
      • Monitor(s):
      • 19" and 15"

    all java files in one

    hi for college i have had to make various applications
    of which most of them have used some kind of pictures
    and to do this i have allways had to have the images in a seperate folder
    i wanted to know (if possible) how to put the images and other files into the one file (.jar)
    also what DataBase does java use? can it use mysql or does java have its own database?

  2. #2
    Senior Member
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,456
    Thanks
    100
    Thanked
    75 times in 51 posts
    • Mblaster's system
      • Motherboard:
      • ASUS PK5 Premium
      • CPU:
      • Intel i5 2500K
      • Memory:
      • 8gb DDR3
      • Storage:
      • Intel X25 SSD + WD 2TB HDD
      • Graphics card(s):
      • Nvidia GeForce GTX 570
      • PSU:
      • Corsair HX520
      • Case:
      • Antec P180
      • Operating System:
      • Windows 7 Professional x64
      • Monitor(s):
      • HP w2207 (22" wide)
      • Internet:
      • Rubbish ADSL

    Re: all java files in one

    Yes you can include images and other non-java files in your jar, there's some info on creating jar files here: http://www.cs.princeton.edu/introcs/...n/jar/jar.html

    As for the databases, Java can connect to all the major databases; MySQL, Oracle, DB2, SQL Server, etc.. For more information search for JDBC (Java DataBase Connectivity).
    I don't mean to sound cold, or cruel, or vicious, but I am so that's the way it comes out.

  3. Received thanks from:

    richy19 (14-06-2010)

  4. #3
    Member
    Join Date
    Jan 2010
    Location
    suffolk
    Posts
    113
    Thanks
    6
    Thanked
    9 times in 9 posts
    • richy19's system
      • Motherboard:
      • Dell e520
      • CPU:
      • intel e4300 OC 2.4ghz
      • Memory:
      • 2gb pc5200
      • Storage:
      • 550gb
      • Graphics card(s):
      • sapphire hd 4650
      • PSU:
      • Dell
      • Case:
      • Dell e520
      • Operating System:
      • Windows 7
      • Monitor(s):
      • 19" and 15"

    Re: all java files in one

    thanks it looks like it will do the trick
    i was wondering if theres an easyer way of doing it with netbeans? other than creating the manifest and using cmd promp

  5. #4
    Senior Member
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,456
    Thanks
    100
    Thanked
    75 times in 51 posts
    • Mblaster's system
      • Motherboard:
      • ASUS PK5 Premium
      • CPU:
      • Intel i5 2500K
      • Memory:
      • 8gb DDR3
      • Storage:
      • Intel X25 SSD + WD 2TB HDD
      • Graphics card(s):
      • Nvidia GeForce GTX 570
      • PSU:
      • Corsair HX520
      • Case:
      • Antec P180
      • Operating System:
      • Windows 7 Professional x64
      • Monitor(s):
      • HP w2207 (22" wide)
      • Internet:
      • Rubbish ADSL

    Re: all java files in one

    Not used Netbeans before, but you can do it though the GUI in Eclipse so I'd imagine there's a way to export to jar in Netbeans too, Google is your friend...
    I don't mean to sound cold, or cruel, or vicious, but I am so that's the way it comes out.

  6. #5
    Moderator DavidM's Avatar
    Join Date
    Jan 2005
    Posts
    8,779
    Thanks
    802
    Thanked
    252 times in 234 posts

    Re: all java files in one

    Just getting to grips with Eclipse myself for coding - really nice!

  7. #6
    Member
    Join Date
    Jan 2010
    Location
    suffolk
    Posts
    113
    Thanks
    6
    Thanked
    9 times in 9 posts
    • richy19's system
      • Motherboard:
      • Dell e520
      • CPU:
      • intel e4300 OC 2.4ghz
      • Memory:
      • 2gb pc5200
      • Storage:
      • 550gb
      • Graphics card(s):
      • sapphire hd 4650
      • PSU:
      • Dell
      • Case:
      • Dell e520
      • Operating System:
      • Windows 7
      • Monitor(s):
      • 19" and 15"

    Re: all java files in one

    just thought i would say how i managed to (finally) do this

    Adding a Package for the Image

    When you use images or other resources in an application, typically you create a separate Java package for the resources. On your local filesystem, a package corresponds with a folder.
    To create a package for the image:
    In the Projects window, right-click the org.me.myimageapp node and choose New > Java Package.



    In the New Package wizard, add .resources to org.me.myimageapp so that the new package is called org.me.myimageapp.resources.
    Click Finish.
    In the Projects window, you should see the image appear within the org.me.myimageapp.resources package.

    then you insert the images into the new folder that has been created (which should be in the same folder as your .java file)

    and use this to "get" the image

    button.setIcon(new ImageIcon(this.getClass().getResource("resources/myIcon.gif")));

  8. Received thanks from:

    DavidM (16-06-2010)

  9. #7
    Member
    Join Date
    Jan 2010
    Location
    suffolk
    Posts
    113
    Thanks
    6
    Thanked
    9 times in 9 posts
    • richy19's system
      • Motherboard:
      • Dell e520
      • CPU:
      • intel e4300 OC 2.4ghz
      • Memory:
      • 2gb pc5200
      • Storage:
      • 550gb
      • Graphics card(s):
      • sapphire hd 4650
      • PSU:
      • Dell
      • Case:
      • Dell e520
      • Operating System:
      • Windows 7
      • Monitor(s):
      • 19" and 15"

    Re: all java files in one

    hm ok so that works with images but not with files
    i have a midi file that when i try to do that it says it wants a java.io.file and it has a url
    i have tryed to convert it but it wont let me

  10. #8
    Senior Member
    Join Date
    Jul 2004
    Location
    London
    Posts
    2,456
    Thanks
    100
    Thanked
    75 times in 51 posts
    • Mblaster's system
      • Motherboard:
      • ASUS PK5 Premium
      • CPU:
      • Intel i5 2500K
      • Memory:
      • 8gb DDR3
      • Storage:
      • Intel X25 SSD + WD 2TB HDD
      • Graphics card(s):
      • Nvidia GeForce GTX 570
      • PSU:
      • Corsair HX520
      • Case:
      • Antec P180
      • Operating System:
      • Windows 7 Professional x64
      • Monitor(s):
      • HP w2207 (22" wide)
      • Internet:
      • Rubbish ADSL

    Re: all java files in one

    If it wants a java.io.File object then create one with: new File("path_string"), but not sure what 'it' is that requires the file object. The getResource() method returns a java.net.URL object, which works for creating an ImageIcon, but may not work for some other kind of file access.

    Also, creating a package like that for the resources seems pretty odd to me (even though a package is just a folder), since your resources will be located in the source folder...
    Last edited by Mblaster; 16-06-2010 at 09:09 PM.
    I don't mean to sound cold, or cruel, or vicious, but I am so that's the way it comes out.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. All files corrupted?
    By ricky101 in forum Help! Quick Relief From Tech Headaches
    Replies: 7
    Last Post: 27-02-2010, 07:15 PM
  2. Potential HUGE source of free Java games / apps
    By PriestJPN in forum Smartphones and Tablets
    Replies: 4
    Last Post: 03-11-2004, 01:59 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
  •