10 Replies Latest reply: May 20, 2008 1:31 PM by 807591 RSS

    Open .RAR or .CAB files in java

    807591
      Well i would like to open a .RAR file or a .CAB and just read the files in it.
      then if i have a password i would like to give it in a text box and it should open my .RAR file in the background.

      that is the basis.

      i just want that my program is not in a .jar file but in a rar file...

      so i have a files.rar and a run.exe
      in the files.rar are the files that i must run from the run.exe
      so i just klick on the run.exe and if i would have a game in the files.rar it should run a file that starts the game.

      what i need from you:
      i need the code that opens the .rar files and runs the .exe in it...
      but the rar file has pa password...
      public class RarOpener
      {
      private String password = "test";
      
      public void opener()
      {
      //open rar with password = "test"
      run();
      }
      
      public void run()
      {
      //run a specific .exe file in the rar file...
      }
      }
      i hope you understand me. sorry for my bad english.
      i don't know if its possible but u are the master...

      thx
        • 1. Re: Open .RAR or .CAB files in java
          807591
          Why do you want to use .rar or .cab to package your Java application? Why can you not just create a jar file?

          Java has built-in support for reading from .zip and .jar files. If you want to be able to read .rar or .cab files, you'll have to find a library that does so, or implement it yourself (probably not what you want to do).
          • 2. Re: Open .RAR or .CAB files in java
            807591
            well it would be ok with zip aswell...

            look: i want to make a programm. that i want to zip it and give it a password so it can not be opened...
            (i want to make it with a zip because its not realy java...)
            then in the run.exe or run.jar should be the classen for the main programm from where it opens the .zip file and runs it...

            hope this can help you ...
            • 3. Re: Open .RAR or .CAB files in java
              807591
              Well, if you want your run ".exe" to be in Java (which is what it sounds like from your first post), having everything else in a password-protected archive won't be very effective. Someone could just decompile your Java starter application to find the password.
              • 4. Re: Open .RAR or .CAB files in java
                807591
                but i will be using the .class files...
                that isn't very easy to decompyle...
                • 5. Re: Open .RAR or .CAB files in java
                  807591
                  error777 wrote:
                  but i will be using the .class files...
                  that isn't very easy to decompyle...
                  It's easy to disassemble and, very easy to find constants. You can write a ClassLoader which loads classes from an encrypted file OK, the problem is that all the data you need to decrypt it has to be present in the unencrypted part of the program. And you can get into those parts with a debugger and stop at the point where the key has been put together.
                  • 6. Re: Open .RAR or .CAB files in java
                    807591
                    so what is your prupouse???
                    how should i do it if:

                    i want to play a game from a .zip file with password protected.
                    • 7. Re: Open .RAR or .CAB files in java
                      807591
                      error777 wrote:
                      so what is your prupouse???
                      how should i do it if:

                      i want to play a game from a .zip file with password protected.
                      It's more practical if the key is outside the program, e.g. you type it in. You can use a password to generate a SecretKey object, then encrypt class files using one of the built-in symmetrical encryption methods available from the library. However you won't protect your copyright like this. Anyone who can play the game can decompile it.
                      • 8. Re: Open .RAR or .CAB files in java
                        807591
                        hmm...
                        so how could i protect very well my files... or my game???

                        there must be a method, because this is very important
                        • 9. Re: Open .RAR or .CAB files in java
                          807591
                          this is what i have sofar
                          import javax.swing.*;
                          import java.awt.*;
                          import javax.swing.event.*;
                          import java.awt.event.*;
                          
                          public class Installer extends JPanel implements ActionListener
                          {
                              protected JButton b1,b2,b3;
                          
                              public Installer() 
                              {
                                  ImageIcon leftButtonIcon = createImageIcon("images/run.gif");
                                  ImageIcon middleButtonIcon = createImageIcon("images/install.gif");
                                  ImageIcon rightButtonIcon = createImageIcon("images/purge.gif");
                          
                                  b1 = new JButton("Run");//, leftButtonIcon);
                                  b1.setVerticalTextPosition(AbstractButton.BOTTOM);
                                  b1.setHorizontalTextPosition(AbstractButton.LEADING);
                                  b1.setMnemonic(KeyEvent.VK_R);
                                  b1.setActionCommand("1");
                                  b1.setEnabled(true);
                          
                                  b2 = new JButton("Install");//, middleButtonIcon);
                                  b2.setVerticalTextPosition(AbstractButton.BOTTOM);
                                  b2.setHorizontalTextPosition(AbstractButton.CENTER);
                                  b2.setMnemonic(KeyEvent.VK_I);
                                  b1.setActionCommand("2");
                                  b1.setEnabled(true);
                          
                                  b3 = new JButton("Purge");//, rightButtonIcon);
                                  b3.setVerticalTextPosition(AbstractButton.BOTTOM);
                                  b3.setHorizontalTextPosition(AbstractButton.TRAILING);
                                  b3.setMnemonic(KeyEvent.VK_P);
                                  b1.setActionCommand("3");
                                  b3.setEnabled(true);
                          
                                  b1.setToolTipText("Run a installed game...");
                                  b2.setToolTipText("Install a game...");
                                  b3.setToolTipText("Purge the process...");
                                  
                                  b1.addActionListener(this);
                                  b2.addActionListener(this);
                                  b3.addActionListener(this);
                              }
                              
                              public static void createPlatform()
                              {
                                  //JFrame.setDefaultLookAndFeelDecorated(true);
                                  JFrame frame = new JFrame("ERROR777 - by Joseph Miclaus");
                                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                                  frame.setIconImage(new ImageIcon("images/icon.gif").getImage());
                                  
                                  Installer newContentPane = new Installer();
                                  newContentPane.setOpaque(true);
                                  frame.setContentPane(newContentPane);
                                  
                                  JLabel label_1 = new JLabel("    Welcome to the first usable error! This is ERROR777 - by Joseph Miclaus! Try not to crack it! Have fun!");
                                  label_1.setOpaque(true);
                                  frame.getContentPane().add(label_1, BorderLayout.CENTER);
                                  //label_1.setVerticalTextPosition(JLabel.TOP);
                                  //label_1.setVerticalAlignment(JLabel.TOP);
                                  frame.setPreferredSize(new Dimension(600,500));
                                  frame.setResizable(false);
                                  
                                  frame.pack();
                                  frame.setVisible(true);
                              }
                          
                              public void actionPerformed(ActionEvent e) 
                              {
                                  if("1".equals(e.getActionCommand()))
                                  {
                                      createPlatformRun();
                                      System.out.println("Run");
                                  }
                                  else if("2".equals(e.getActionCommand()))
                                  {
                                      createPlatformInstall();
                                      System.out.println("Install");
                                  }
                                  else
                                  {
                                      System.out.println("Exit");
                                      System.exit(0);
                                  }
                              } 
                              
                              protected static ImageIcon createImageIcon(String path) 
                              {
                                  java.net.URL imgURL = Installer.class.getResource(path);
                                  return new ImageIcon(imgURL);
                              }
                              
                              public static void main(String[] args) 
                              {
                                  javax.swing.SwingUtilities.invokeLater(new Runnable() 
                                  {
                                      public void run() 
                                      {
                                          createPlatform();
                                      }
                                  });
                              }
                          }
                          well at the end it should be suposed that my friends can NOT copy the game or files that i give them...
                          so i just put a Files.zip in the install directory with everytime the same password and it should install a single .exe file on the desktop... so a shortcut...
                          after it installd the exe file it should be able tu run... in the run thing should open a window where you can choose all installed exe files...
                          and purge its just for the System.exit(0);

                          but i still need your help...

                          thx

                          Edited by: error777 on May 19, 2008 1:58 PM

                          Edited by: error777 on May 19, 2008 2:02 PM
                          • 10. Re: Open .RAR or .CAB files in java
                            807591
                            nobody???