Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Client error

  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Client error

    im trying to jar my client and make the cache download from a website to the users home so the client is more universal. its really starting to piss me off. it wont connect to the server and i get the this error when i debug it.

    java.io.FileNotFoundException: nullIcache31\sprites.dat (The system cannot find
    the path specified)
            at java.io.RandomAccessFile.open(Native Method)
            at java.io.RandomAccessFile.<init>(Unknown Source)
            at java.io.RandomAccessFile.<init>(Unknown Source)
            at CustomSprites.loadCustomSprites(CustomSprites.java:11)
            at Gui.<init>(Gui.java:109)
            at Gui.main(Gui.java:38)

    here is my code

        public static void loadCustomSprites(client var_client) {
            try {
                RandomAccessFile cache = new RandomAccessFile(System.getProperty("home") + "Icache31/sprites.dat", "r");
                RandomAccessFile cache_idx = new RandomAccessFile(System.getProperty("home") + "Icache31/sprites.idx", "r");
                Cache ch = new Cache(cache, cache_idx, 0);
                Map<String, Image> images = new HashMap<String, Image>();
                for(int i=0; i < ch.getNumFiles(); i++) {
                    byte[] buffer = ch.getFile(i);
                    if(buffer == null) {
                        continue;
                    }
                    DataStream str = new DataStream(buffer.length, 0);
                    System.arraycopy(buffer, 0, str.inBuffer, 0, buffer.length);
                    String name = str.readString();
                    Image img = Toolkit.getDefaultToolkit().createImage(str.inBuffer, str.readOffset(), str.inBuffer.length - str.readOffset());
                    if(img != null) {
                        images.put(name, img);
                    }
                }
                MediaTracker mediaTracker = new MediaTracker(var_client);
                for(Image i : images.values()) {
                    mediaTracker.addImage(i, 0);
                }
                try {
                    mediaTracker.waitForAll();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                for(String name : images.keySet()) {
                    Image i = images.get(name);
                    if(i == null) {
                        continue;
                    }
                    int[] pixels = new int[i.getWidth(null) * i.getHeight(null)];
                    PixelGrabber pixelgrabber = new PixelGrabber(i, 0, 0, i.getWidth(null), i.getHeight(null), pixels, 0, i.getWidth(null));
                    pixelgrabber.grabPixels();
                    sprites.put(name, pixels);
                }
                //System.out.println("" + sprites.size() + " sprites successfully loaded!");
            } catch(Exception e) {
                e.printStackTrace();
            }
        }

    when i did "user.home" it went to C:/OwnerIcache31/sprites.dat

    wich is not right.. please help!


  2. #2
    Junior Member
    Join Date
    Feb 2011
    Posts
    19
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Client error

    Well, why not try specifying right paths?

  3. #3
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Client error

    because the point of it is so that any user can download 1 client and use it no matter what OS they have.

Similar Threads

  1. web service client
    By maverick257 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 24th, 2010, 03:59 AM
  2. IRC client
    By Brt93yoda in forum The Cafe
    Replies: 14
    Last Post: November 26th, 2010, 04:31 PM
  3. Client/Server
    By Dillz in forum Paid Java Projects
    Replies: 2
    Last Post: June 2nd, 2010, 05:19 AM
  4. RMI over SSL Client application
    By boilerchicken in forum Java Networking
    Replies: 0
    Last Post: November 10th, 2009, 07:52 AM
  5. [SOLVED] web client
    By 5723 in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: June 10th, 2009, 04:44 PM