Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • Cole1497: join horney scape we are horney all the time and have a sex emote
      November 09, 2019, 05:14:33 PM
    • thewraith500: try autoscape,0rg brand new osrs CUSTOMS server! fight caves for flaming fire cape, upgrade them to infernal wings + more!
      November 09, 2019, 01:37:29 AM
    • SuperNativeZ: Come play brand new server [link]
      November 08, 2019, 02:13:24 PM
    • SuperNativeZ: Come play brand new server [link]
      November 08, 2019, 02:13:17 PM
    • SuperNativeZ: Come play brand new server [link]
      November 08, 2019, 02:13:14 PM
    • ragnoroker: Brand new server, come join the fun - unique server - RuneGuild - [link]
      November 07, 2019, 11:55:44 AM
    • ragnoroker: Brand new server, come join the fun - unique server - RuneGuild - [link]
      November 07, 2019, 11:55:40 AM
    • ragnoroker: Brand new server, come join the fun - unique server - RuneGuild - [link]
      November 07, 2019, 11:55:35 AM
    • ArtexAdv: Come play brand new server [link]
      November 07, 2019, 07:36:34 AM
    • grefin::cool:
      November 04, 2019, 12:55:57 AM
    • grefin: Hi friends! I cant get through that bank pin thing. What should i do my friends?
      November 04, 2019, 12:55:36 AM
    • cows1471: its weird
      November 03, 2019, 02:56:40 PM
    • cows1471: fudge me
      November 03, 2019, 02:56:34 PM
    • cows1471: my original account is 11 years ago
      November 03, 2019, 02:56:26 PM
    • cows1471: and yet
      November 03, 2019, 02:56:14 PM
    • Christmas_tree: this place has changed
      November 03, 2019, 02:54:34 PM
    • Christmas_tree: fudge me
      November 03, 2019, 02:54:25 PM
    • Christmas_tree: six years ago i registered this account
      November 03, 2019, 02:54:22 PM
    • thewraith500: everyone join autoscape,0rg its the best customs osrs server yet! the owner gives ultra boxes!
      October 28, 2019, 08:03:09 PM
    • gameruler93: I am so fudgeing glad to see this website is still alive.
      October 28, 2019, 07:57:18 PM

    Author Topic: [Any] Client Launcher/Updater  (Read 6820 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineFox2007

    • Member
    • ****
    • Posts: 567
    • Thanks: +0/-0
      • View Profile
    [Any] Client Launcher/Updater
    « on: February 24, 2014, 12:10:22 AM »
    First, no I did not choose to livestream the jar file, this would consume a lot of bandwidth on large servers and some people use shitty hosting with limited bandwidth. This was also just something I made in my spare time to learn something about swing, so please no hate ;_;

    You could also use this to get rid of the shitty checking in most 317 clients where you have to change a number and all that other shit. This will compare dates to the file stored online, and if It's newer it will prompt you for the download. Works only for clients, not the cache.
    ----------
    Preview:
    (click to show/hide)


    First, you need to make a new folder, call it whatever you like. Then inside, you need to make this structure:


    • Main Folder
      -- bin/ (output folder)
      -- src/
      ---- Launcher.java
      ---- Splash.java
    Splash.java:
    Code: Java
    1. importjavax.swing.*;
    2.  /**
    3.   * @author King Fox
    4.   */
    5. publicclass Launcher {
    6.    
    7.     publicstaticvoid main(String[] args){
    8.         final Splash s =new Splash();
    9.          s.setVisible(true);
    10.          SwingUtilities.invokeLater(newRunnable(){
    11.              publicvoid run()  {
    12.                   s.setVisible(true);
    13.              }
    14.          });
    15.     }
    16.  
    17. }
    18.  

    Launcher.java:
    Code: Java
    1. importjavax.swing.*;
    2.  
    3.  
    4. importjava.awt.*;
    5. importjava.io.*;
    6. importjavax.swing.*;
    7. importjava.io.*;
    8. importjava.net.*;
    9.  
    10. @SuppressWarnings("serial")
    11. publicclass Splash extendsJFrame{
    12.  
    13. // START EDIT
    14.    privatestaticString downloadUrl =";; // the download url
    15.   private static String fileName = "SomeJar.jar"; // the name you wish to save it as
    16.   private static String serverName = "Foxtrot"; // the server name
    17.   private static String backgroundImageUrl = ";;// url to a background image
    18.    privatestaticString saveDirectory =System.getProperty("user.home")+"/Desktop/";// the location where you wish to store the Jar
    19. // END EDIT
    20.  
    21.    publicstaticURL url;
    22.    privateJLabel imglabel;
    23.    privateImageIcon img;
    24.    privatestaticJProgressBar pbar;
    25.    Thread t =null;
    26.  
    27.    public Splash(){
    28.       super("Splash");
    29.        
    30.       File file =newFile(saveDirectory + fileName);
    31.        
    32.       try{
    33.          url =newURL(downloadUrl);
    34.       }catch(MalformedURLException e){
    35.          e.printStackTrace();
    36.       }
    37.      
    38.       setSize(543, 391);
    39.       setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    40.       setLocationRelativeTo(null);
    41.       setUndecorated(true);
    42.        
    43.       try{
    44.          img =newImageIcon(newURL(backgroundImageUrl));
    45.       }catch(MalformedURLException e1){
    46.          e1.printStackTrace();
    47.       }
    48.        
    49.       imglabel =newJLabel(img);
    50.       add(imglabel);
    51.       setLayout(null);
    52.       pbar =newJProgressBar();
    53.       pbar.setMinimum(0);
    54.       pbar.setMaximum(100);
    55.       pbar.setStringPainted(true);
    56.       pbar.setForeground(Color.LIGHT_GRAY);
    57.       imglabel.setBounds(0, 0, 543, 391);
    58.       add(pbar);
    59.       pbar.setPreferredSize(newDimension(310, 30));
    60.       pbar.setBounds(70, 320, 404, 20);
    61.  
    62.  
    63.       try{
    64.          if(file.exists()){
    65.             URLConnection connection = url.openConnection();
    66.             connection.connect();
    67.             long time = connection.getLastModified();
    68.             if(time > file.lastModified()){
    69.                if(!startDialogue()){
    70.                   startApplication();
    71.                   return;
    72.                }
    73.             }else{
    74.                setVisible(true);
    75.                Thread.sleep(3000);
    76.                startApplication();
    77.                return;
    78.             }
    79.          }
    80.       }catch(Exception e){
    81.          e.printStackTrace();
    82.       }
    83.        
    84.       Thread t =newThread(){
    85.  
    86.          publicvoid run(){
    87.             OutputStream dest =null;
    88.             URLConnection download;
    89.             InputStream readFileToDownload =null;
    90.             try{
    91.                dest =newBufferedOutputStream(newFileOutputStream(saveDirectory + fileName));
    92.                download = url.openConnection();
    93.                readFileToDownload = download.getInputStream();
    94.                byte[] data =newbyte[1024];
    95.                int numRead;
    96.                long numWritten =0;
    97.                int length = download.getContentLength();
    98.                while((numRead = readFileToDownload.read(data))!=-1){
    99.                   dest.write(data, 0, numRead);
    100.                   numWritten += numRead;
    101.                   int percent =(int)(((double)numWritten /(double)length)* 100D);
    102.                   pbar.setValue(percent);
    103.                   pbar.setString(""+(percent <99?"Downloading "+serverName+" - "+percent+"%":"Complete")+"");
    104.                }
    105.             }catch(Exception exception){
    106.                exception.printStackTrace();
    107.             }finally{
    108.                try{
    109.                   if(readFileToDownload !=null)
    110.                      readFileToDownload.close();
    111.                   if(dest !=null)
    112.                      dest.close();
    113.                   Thread.sleep(1000L);
    114.                   startApplication();
    115.                }catch(IOException|InterruptedException ioe){
    116.                
    117.                }
    118.             }
    119.          }
    120.       };
    121.       t.start();
    122.    }
    123.    
    124.    publicboolean startDialogue(){
    125.       setVisible(true);
    126.       int selection =JOptionPane.showConfirmDialog(null, "An update is available. Do you wish to download?", "Update Available", JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
    127.       return selection ==JOptionPane.OK_OPTION;
    128.    }
    129.  
    130.  
    131.    /**
    132.    * Launches the downloaded Jar file and closes the progress bar
    133.    */
    134.    publicstaticvoid startApplication(){
    135.       try{
    136.          Runtime.getRuntime().exec("java -jar "+(saveDirectory + fileName)+"");
    137.          Thread.sleep(1000L);
    138.          System.exit(0);
    139.       }catch(IOException|InterruptedException e){
    140.          e.printStackTrace();
    141.       }
    142.    }
    143.  
    144. }
    145.  

    Suggested you do this with an IDE such as Eclipse.
    Hopefully someone finds use for it ^-^ Splash.java contains all the information you need to edit.
    « Last Edit: February 25, 2014, 07:53:46 PM by Fox2007 »
    Foxtrot Studios - The next generation of java and web-development
    Runescape Gambling

    OfflineVain_

    • Member
    • ****
    • Posts: 3,057
    • Thanks: +0/-0
      • View Profile
    Re: [Any] Client Launcher/Updater
    « Reply #1 on: February 24, 2014, 09:27:44 AM »
    useful to pushing out updates, but only if the user chooses to download it. id remove the prompt and just download it directly.

    another alternative would be runajar,  but of course will only be useful to servers with large bandwidth. it essentially runs the archive from the URL, without downloading anything except the cache. would basically run the client on the webserver, which would only be updated by the host.

    I use runajar personally because I can have one jar file, and quite a few shell scripts/batch commands and run any number of clients I want, only using different parameters. it saves hd space for all the servers I play from time to time.

    Offlinelare69

    • Member
    • ****
    • *
    • Posts: 5,322
    • Thanks: +0/-0
      • View Profile
    Re: [Any] Client Launcher/Updater
    « Reply #2 on: March 11, 2014, 07:30:39 AM »
    useful to pushing out updates, but only if the user chooses to download it. id remove the prompt and just download it directly.

    another alternative would be runajar,  but of course will only be useful to servers with large bandwidth. it essentially runs the archive from the URL, without downloading anything except the cache. would basically run the client on the webserver, which would only be updated by the host.

    I use runajar personally because I can have one jar file, and quite a few shell scripts/batch commands and run any number of clients I want, only using different parameters. it saves hd space for all the servers I play from time to time.
    NERD

    just kidding :) pretty good release although I agree that they shouldn't be prompted and it should just download directly
    hi. check out luna:)

    Offlinetaymor46

    • First Time Poster
    • *
    • Posts: 3
    • Thanks: +0/-0
      • View Profile
    Re: [Any] Client Launcher/Updater
    « Reply #3 on: September 07, 2016, 11:52:29 AM »
    can any one help me to add this auto client updater to my server
    ill pay for him!!

    skype : taymor gadban

    mail : [email protected]

     

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