Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • SOUPSOUP: just get a vpn
      August 13, 2018, 06:44:28 PM
    • jme: _^_ will answer all of your javascript questions
      August 12, 2018, 07:11:00 PM
    • doomsale: and where is boxman?
      August 10, 2018, 03:16:59 AM
    • doomsale: Where can i play the Moparscape MMORPG with the Metallica instrumentals?
      August 10, 2018, 03:16:47 AM
    • doomsale: no longer clicking on doors and dummies at east bank
      August 10, 2018, 03:16:07 AM
    • doomsale: were all grown up now huh?
      August 10, 2018, 03:15:58 AM
    • _^_: hey everyone look at my graphs [link]
      August 06, 2018, 01:52:16 PM
    • braedyn: Someone pl0x help me out with PI Lottery!!
      August 03, 2018, 02:12:25 AM
    • Travas: p3n1s
      July 26, 2018, 09:46:33 PM
    • Krackkid: You up :eggplant:
      July 23, 2018, 06:18:17 PM
    • DeathsChaos9: no
      July 23, 2018, 03:53:31 PM
    • Emulous: Come check out Emulous: [link]
      July 22, 2018, 03:37:19 PM
    • Emulous:[link]
      July 22, 2018, 03:37:00 PM
    • Travas: ur mom
      July 21, 2018, 06:04:50 PM
    • YNRDAB: Watcha big ballers up too?
      July 20, 2018, 11:01:06 AM
    • dark250: i need help for coding client
      July 19, 2018, 08:27:37 AM
    • Travas: yes
      July 14, 2018, 02:19:44 PM
    • drubrkletern: lmao racist and sexist much?
      July 14, 2018, 01:11:52 PM
    • Cole1497: yeah i got you lil boat give me a second
      July 13, 2018, 03:19:35 AM
    • B0ATY.: yo can anyone unban my ip, i got banned for saying i hope someone gets aids :p
      July 12, 2018, 09:16:00 PM

    Author Topic: PI Client help  (Read 611 times)

    0 Members and 1 Guest are viewing this topic.

    Offlineemiros

    • Member
    • **
    • Posts: 7
    • Thanks: +0/-0
      • View Profile
    PI Client help
    « on: July 12, 2015, 12:25:35 AM »
    Hi guys, When i run my client on Eclipse it loads my cache perfectly and runs the client but when I export it to Jar and run it gives me this error
    Any help??
    Runescape Gambling

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: PI Client help
    « Reply #1 on: July 12, 2015, 12:59:33 AM »
    Hi guys, When i run my client on Eclipse it loads my cache perfectly and runs the client but when I export it to Jar and run it gives me this error
    Any help??
    The error is because the jar does not have permission to access the directory.
    Sign your jar file and that should fix it (Exporting it in eclipse does not sign it afaik)
    Runescape Gambling

    Offlineemiros

    • Member
    • **
    • Posts: 7
    • Thanks: +0/-0
      • View Profile
    Re: PI Client help
    « Reply #2 on: July 12, 2015, 01:52:55 AM »
    So what do I do exactly?
    Runescape Gambling


    Offlineemiros

    • Member
    • **
    • Posts: 7
    • Thanks: +0/-0
      • View Profile
    Re: PI Client help
    « Reply #4 on: July 12, 2015, 02:21:21 AM »
    I done it still failed. willing to do it?? i'll pay if it works

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: PI Client help
    « Reply #5 on: July 12, 2015, 02:44:06 AM »
    I done it still failed. willing to do it?? i'll pay if it works
    https://stackoverflow.com/questions/15915349/why-is-my-program-denying-access-to-create-a-file
    This may be a cause.
    Essentially, windows may be blocking the access (That's actually why i had you sign it).
    Can i see the code for UpdateCache.java?

    Offlineemiros

    • Member
    • **
    • Posts: 7
    • Thanks: +0/-0
      • View Profile
    Re: PI Client help
    « Reply #6 on: July 12, 2015, 02:52:12 AM »
    package com.cache;

    import java.awt.List;
    import java.io.BufferedInputStream;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.net.URL;
    import java.net.URLConnection;
    import java.nio.file.Files;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipInputStream;

    import javax.swing.JOptionPane;

    import org.apache.commons.io.FileUtils;
    import org.apache.commons.io.IOUtils;

    import com.Client;

    public class UpdateCache implements Runnable {

       public static final String ZIP_URL = ";;
       public static final String VERSION_URL = ";;
       public static final String VERSION_FILE = SignLink.findcachedir()+"cacheVersion.dat";
       private Client client;
       Client frame;
        public UpdateCache(Client client) {
                    this.client = client;
        }
          
        private void drawLoadingText(int amount, String text) {
                    client.drawLoadingText(amount, text);
        }
       
       public double getCurrentVersion(){
          try {
             br = new BufferedReader(new InputStreamReader(new FileInputStream(VERSION_FILE)));
             return Double.parseDouble(br.readLine());
          } catch (Exception e) {
             return 0.1;
          }
       }
       
       public double getNewestVersion(){
          try {
             URL tmp = new URL(VERSION_URL);
             File file = new File("./version.txt");
             if (!file.exists())
                file.createNewFile();
             FileUtils.copyURLToFile(tmp, file);
             FileInputStream fis = new FileInputStream(file);
             return Double.parseDouble(IOUtils.toString(fis));
          } catch (Exception e) {
             handleException(e);
             return -1;
          }
       }
       
       private void handleException(Exception e){
          StringBuilder strBuff = new StringBuilder();
          strBuff.append("Please Screenshot this message, and send it to an admin!\r\n\r\n");
            StringBuilder append = strBuff.append(e.getClass().getName()).append(" \"").append(e.getMessage()).append("\"\r\n");
          for(StackTraceElement s : e.getStackTrace())
             strBuff.append(s.toString()).append("\r\n");
          alert("Exception [" + e.getClass().getSimpleName() + "]",strBuff.toString(),true);
       }
       
       private void alert(String msg){
          alert("Message",msg,false);
       }
       
       private void alert(String title,String msg,boolean error){
          JOptionPane.showMessageDialog(null,
                msg,
                title,
                 (error ? JOptionPane.ERROR_MESSAGE : JOptionPane.PLAIN_MESSAGE));
       }
       
       @Override
       public void run() {
       drawLoadingText(0, "Checking Client Version");
          try{
          double newest = getNewestVersion();
          if(newest > this.getCurrentVersion()){
             int n = JOptionPane.showConfirmDialog(
                    null,
                    "There is an update to version " + newest + "\n" +
                   "Would you like to update?",
                    "Current version: "+ getCurrentVersion(),
                    JOptionPane.YES_NO_OPTION);
             if(n == 0){
                updateClient();
                drawLoadingText(0, "Cache Download Is Complete!");
                alert("Cache Download Is Complete, The Client Will Run Now.");
                out = new FileOutputStream(VERSION_FILE);
                out.write(String.valueOf(newest).getBytes());;
                client.start();
             }else{
                alert("You are currently loading V: " +
                getCurrentVersion() + " and the latest version is V: " + newest + "\n" + " Make sure to update.");
                //System.exit(0);
             }
          }
          }catch(Exception e){
             handleException(e);
          }
       }
       
       private void updateClient() {
          File clientZip = downloadClient();
          if(clientZip != null){
          unZip(clientZip);
          }
       }
       
       private void unZip(File clientZip) {
          try {
             unZipFile(clientZip,new File(SignLink.findcachedir())); //I can check to see if I can fix that ok
             clientZip.delete();
          } catch (IOException e) {
             handleException(e);
          }
       }
       
       private void unZipFile(File zipFile,File outFile) throws IOException{
          ZipInputStream zin = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFile)));
          ZipEntry e;
          long max = 0;
          long curr = 0;
          while((e = zin.getNextEntry()) != null)
             max += e.getSize();
          zin.close();
          in = new ZipInputStream(new BufferedInputStream(new FileInputStream(zipFile)));
          while((e = in.getNextEntry()) != null){
             if(e.isDirectory())
                new File(outFile,e.getName()).mkdirs();
             else{
                FileOutputStream out = new FileOutputStream(new File(outFile,e.getName()));
                byte[] b = new byte[1024];
                int len;
                while((len = in.read(b,0,b.length)) > -1){
                   curr += len;
                      out.write(b, 0, len);
                      setUnzipPercent((int)((curr * 100) / max));
                }
                out.flush();
                out.close();
             }
          }
       }

       public int percent = 0;
       
       public void setDownloadPercent(int amount){
               percent = amount;
             drawLoadingText(amount, "Downloading .SPrime Cache" + " - " + amount + "%");
       }
       
       public int percent2 = 0;
       private ZipInputStream in;
       private OutputStream out;
       private BufferedReader br;
       
       public void setUnzipPercent(int amount2){
               percent2 = amount2;
             drawLoadingText(amount2, "Extracting .SPrime Cache" + " - " + amount2 + "%");
       }

       private File downloadClient(){
          File ret = new File(SignLink.findcachedir()+"cache.zip");
          try{
          OutputStream out = new FileOutputStream(ret);
          URLConnection conn = new URL(ZIP_URL).openConnection();
          InputStream in = conn.getInputStream();
          long max = conn.getContentLength();
          long curr = 0;
          byte[] b = new byte[1024];
          int len;
          while((len = in.read(b, 0, b.length)) > -1){
             out.write(b,0,len);
             curr += len;
             setDownloadPercent((int)((curr * 100) / max));
          }
          out.flush();
          out.close();
          in.close();
          return ret;
          }catch(Exception e){
             handleException(e);
                ret.delete();
             return null;
          }
       }
    }

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: PI Client help
    « Reply #7 on: July 12, 2015, 03:07:27 AM »
    Code: [Select]
             File file = new File("./version.txt");
             if (!file.exists())
                file.createNewFile();
    This is what is causing your error.
    You could try changing it to:
    Code: Java
    1.          File file =newFile(SignLink.findcachedir()+"version.txt");
    2.          if(!file.exists())
    3.             file.createNewFile();

    Offlineemiros

    • Member
    • **
    • Posts: 7
    • Thanks: +0/-0
      • View Profile
    Re: PI Client help
    « Reply #8 on: July 12, 2015, 03:12:39 AM »
    Changed it and still getting the same error  :palm: do you have skype??
    « Last Edit: July 12, 2015, 04:11:56 AM by emiros »

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal