Protect class Files from Decryption?

Hey. I have a couple of Java classes I wish to share with some people, but I would like to add a copyright/credit giving message into the program. This code is the kind of code people would want to steal and take credit for, which is why I'm only (if I can encrypt them) giving out the .class files and not the source code. The thing is, it took me about 5 seconds of searching on Google to find programs that can easily be used to decrypt .class files and get a re-compilable source from them.
So I was wondering, is there a [somewhat] foolproof way to protect against people decrypting the .class files to get the source? Is there some program I can run them through that will make it so they can't be decompiled, but will still run on a machine with a standard Java runtime installed? I probably won't be giving out the classes if there isn't a way to do this.
Thanks

There are programs out their that semi pseudo scramble your code but if someone wanted to they can always reverse it and have a look at your source. What you have to admit is that your code is nothing special and nobody would really want to steal your code. If you are paranoid about it, about the most you can do is add some copyright message and threaten them with legal action.

Similar Messages

  • How to protect class files from being decompiled?

    any ideas
    guide me

    You may consider looking into Java native compilers.
    I'm referring to compilers that take existing Java
    code and convert them into native executables rather
    than class files which are interpreted.yeah... kills portability too.

  • How to restrict the .class file from decompilation

    Hi all,
    i got a security problem. i need all the java class files to be most secured. is there any to restriction on the java class files from decompilation. is that possible?. pls help me out. it's very urgent
    thanks in advance

    You can make it harder to understand the decompiled code if you use an obfuscator. (I don't have links to any, do a google search, or search these forums, it have been discussed here previously.)
    You cannot completely prevent decompilation, though. Obfuscating does not for example not mean that any passwords you have hardcoded in the source is secure.

  • Running the .class file from java code

    I'm doing a kind of providing service like compiling and running Java code on server side and giving output to the end user.
    Please suggest me an approach with code to run .class file from the Java code.
    import java.io.*;
    public class demo {
    public static void main(String args[]) throws IOException, InterruptedException {
    int result;
    try {
    System.out.println("command output:");
    Process proc = Runtime.getRuntime().exec("java -cp . demoh");
    InputStream in = proc.getInputStream();
    result = proc.waitFor();
    BufferedInputStream buffer = new BufferedInputStream(proc.getInputStream());
    BufferedReader commandOutput = new BufferedReader(new InputStreamReader(buffer));
    String line = null;
    System.out.print(commandOutput);
    try {
    while ((line = commandOutput.readLine()) != null) {
    System.out.print(line);
    System.out.println("command output: " + line);
    }//end while
    commandOutput.close();
    } catch (IOException e) {
    //log and/or handle it
    }//end catc
    } catch (IOException e) {
    System.err.println("IOException raised: " + e.getMessage());
    }

    What happened when you tried what you have there?

  • Tomcat6 does not load class files from WEB-INF/lib/myjarfile.jar  WHY???

    I have placed my jar file in c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jar
    But, after restarting tomcat6, when i try to import the class file contained in the myjarfile.jar in a servlet, it says
    ProcessFileUpload.java:4: package test.test1 does not exist
    import test.test1.*;
    ^It clearly tomcat's class loading problem.
    As i unzipped my jar and placed the packagefolder structure to
    c:\tomcat6\webapps\my-application\WEB-INF\classes\testand it works perfectly.
    Anyone knows its workaround? please suggest if any configuration changes is required in tomcat or so.
    Thanks.
    ---Sujoy

    Thank you gimbal2 . There was error in creating the jar file myjarfile.jar.
    But, now I have created it again and placed it in place
    c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jarand tried to use one on the Class file included within the jar to compile my servlet. But, still I am getting error at servlet compilation time. I want to place executable jar files in
    c:\tomcat6\webapps\my-application\WEB-INF\lib\myjarfile.jar and compile my servlet and execute the servlet.
    I DO NOT WANT TO unzip the jar, placing all unzipped files to
    c:\tomcat6\webapps\my-application\WEB-INF\classes\ folder and comiple my servlet and execute the servlet. But, I am failing to user WEB-INF\lib\ folder facility....please help me why i am not getting class files from WEB-INF\lib\ folder.
    If you please see the small code bit and tell me any possible error that would be very helpful.
    Step 1: my library java file MyClass.java
    package test.test1;
    public class MyClass {
         String myName = "Default return string value";
         public void setMyName(String varName) {
              this.myName = varName;
         public String getMyName() {
              return this.myName;
    }Step2 : Creating jar file of my library class files
    C:\jdk1.6\bin>jar cvf myjarfile.jar test
    added manifest
    adding: test/(in = 0) (out= 0)(stored 0%)
    adding: test/test1/(in = 0) (out= 0)(stored 0%)
    adding: test/test1/MyClass.class(in = 452) (out= 296)(deflated 34%)
    adding: test/test1/MyClass.java(in = 230) (out= 140)(deflated 39%)
    C:\jdk1.6\bin>Step3 : Double checking the created jar file content by listing its content
    C:\jdk1.6\bin>jar tf myjarfile.jar
    META-INF/
    META-INF/MANIFEST.MF
    test/
    test/test1/
    test/test1/MyClass.class
    test/test1/MyClass.java
    C:\jdk1.6\bin>Step4 : Placed myjarfile.jar to
    c:\tomcat6\webapps\my-application\WEB-INF\lib\Step5 : Restarted standalone Tomcat6 in my Windows XP SP2.
    Step6 : Created a simple servlet LibFolderTest.java within my-application\WEB-INF\classes\ folder with code
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import test.test1.*;
    public class LibFolderTest extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              MyClass mc = new MyClass();
              out.println(mc.getMyName());
    }Step7 : Tried to compile my servlet LibFolderTest.java and got the following error
    LibFolderTest.java:4: package test.test1 does not exist
    import test.test1.*;
    ^
    LibFolderTest.java:11: cannot find symbol
    symbol  : class MyClass
    location: class LibFolderTest
                    MyClass mc = new MyClass();
                    ^
    LibFolderTest.java:11: cannot find symbol
    symbol  : class MyClass
    location: class LibFolderTest
                    MyClass mc = new MyClass();
                                     ^
    3 errorsThe above servlet compilation error on Step7 is telling me that myjarfile.jar is not loaded by Tomcat6 or not available for use when compiling servlet. I want to use myjarfile.jar from within WEB-INF\lib\ folder but I can not. please help.
    ---Sujoy

  • How to call class file from jsp without creating packages

    i m using tomcat 5.5
    i stored my class file into WEB-INF\Class directory
    how to call that class file. from my jsp page.
    i got some error.
    i used package concept,that works fine.

    i m using tomcat 5.5
    i stored my class file into WEB-INF\Class directory
    how to call that class file. from my jsp page.
    i got some error.
    i used package concept,that works fine.Then use packages.
    As of Java1.4, you can no longer import classes from the default package (no package declared) into classes that are packaged.
    All Tomcat classes are in packages, including the compiled JSP.
    Therefore: Your classes need to be in a package inorder to be imported and used by the JSP.
    Why the problem? If you know it works with packages, why try not to use them?

  • Running class files from the windows command line...

    Hello Everyone,
    My instructor showed us a way to run class files from the windows command line. However every time I try to run the class file from the command line using a command like: java CruiseHelper.class
    I get an error that states "Exception in thread "main" java.lang.NoClassDefFoundError: CruiseHelper/class"

    Hello Everyone,
    My instructor showed us a way to run class files from
    the windows command line. However every time I try
    to run the class file from the command line using a
    command like: java CruiseHelper.class
    I get an error that states "Exception in thread
    "main" java.lang.NoClassDefFoundError:
    CruiseHelper/class"Classes are not file names. You don't have a class named "CruiseHelper.class", that's a file name. The class name is just CruiseHelper (if you have no package statement in it).
    So,
    java -classpath . CruiseHelper

  • Running  .class file from autoexec.bat (in Windows Xp environment)

    How to run a .class file from autoexec.bat file. I have WinXP installed on my PC. I tried the solution given by Forum memebers but they didn't work.
    after setting the classpath
    i wrote
    java -cp simple in autoexec.bat , but results were not satisfactory.

    What does "not satisfactory" mean? If the commans works from any .bat file, it'll work from autoexec.bat, too.
    May I ask what you're trying to accomplish? I'm not sure whether XP dtill uses autoexec.bat for console initialization after all.

  • Why do I get multiple class files from 1 java file?

    I wrote a dialog box using gridBagConstraints and another program RunPanel to run it as a java application. For the first time since playing with java, I get multiple class files from a single java file.
    This seems very strange to me and wonder if anyone else has come across this and what could possibly be the reason for it. I did a clean (in Eclipse) just to make sure it wasn't garbage and sure enough they come back again.
    I have ReconPanel.java from which I get ReconPanel.class with the addition of ReconPanel$N.class where N goes from 1 to 5.
    The same thing in RunPanel but here there is only 1 extra file, RunPanel$1.class.
    I'll include the code for RunPanel since it is relatively small:
    package ilan;
    import javax.swing.JFrame;
    public class RunPanel extends JFrame {
         private static final long serialVersionUID = 1L;
         private ReconPanel m_reconPanel = null;
         public RunPanel() {
              super();
              initialize();
          * This method initializes this
         private void initialize() {
            this.setTitle("tester");
            this.setSize(new java.awt.Dimension(138,396));
            this.addWindowListener(new java.awt.event.WindowAdapter() {
                 public void windowClosing(java.awt.event.WindowEvent e) {
                      m_reconPanel.exitPanel();
                      System.exit(0);
              m_reconPanel = new ReconPanel();
              this.getContentPane().add(m_reconPanel);
          * @param args
         public static void main(String[] args) {
              JFrame frame1 = new RunPanel();
              frame1.setVisible(true);
    }  //  @jve:decl-index=0:visual-constraint="10,10"The only thing "unusual" I do is to put a listener on the WindowClosing so that I can go back to ReconPanel and write results to the registry.
    Can anyone tell me what is going on?
    Thanks,
    Ilan

    He IIan,
    Yes, you get number of extra class files based on your number of anomyous class es used. Like in your RunPanel, you get only 1 ..$1.class file, b'coz u have used only 1 annomyous class & i.e WindowAdapter. Take a look at this code :-
    this.addWindowListener(new java.awt.event.WindowAdapter() {
                 public void windowClosing(java.awt.event.WindowEvent e) {
                      m_reconPanel.exitPanel();
                      System.exit(0);
            });Similarly, in your ReconPanel, you must have used such kind of classes 5 times, & hence u get such 5 extra classes. To avoiod such extra classes, if you can directly implement that interface or extend the class, if possible will be best. For example, for each button, u write
    button1.addActionListener(new ActionListener() {
    // Code
    });Instead, of this, its better to implement ActionListener & write
    button1.addActionListener(this);
    public void actionPerformed(ActionEvent ae) {
       if (ae.getSource() == button1) {
       // CODE
       }Likethis, you can get rid of such numerous extra class files. In IDE, if you ask to add actionEvent, it will do the first method. To get rid of it, don't add event in the properties, instead, apply the second method. The same thing applies for anyother event. The first option is worthful, if by implementing, u got to write 5 functions from which u r gonna use just 1 method.
    Hope this clears your question.
    Trupti

  • How to protect Conversion file from changes

    Dear All,
    Is there any way to restrict users on change conversion files ? my requirement is, need to protect conversion file from changes.
    I have tried normal Excel password protection,it is not working.
    thanks in advance...
    regards,
    Raju

    Hi Raju,
    Why do you want to protect the conversion file?
    Conversion file is used insight of transformation file only.
    That's means if an user will change the transformation file to use another conversion file it doesn't matter if you protect the conversion file.
    So actaully if I understood correct is that user should not be able to change the conversion and transformation file.
    This can be done in two wat:
    Into task profile don't give to the user access to do Organize package list.
    Second into your DM package eliminate the prompt for transformation file.
    I hope this will help.
    Regards
    Sorin Radulescu

  • Executing class files from a Java App dynamically

    Hi!, Is there any way i can execute java .class files from my Java Application dynamically. I know that java uses Dynamic method Invocation. Is that true of class files generated using some other language compiled for the JVM.
    In my case i would like to make a Web browser that interprets HTML and also java applets embeded in them. I would like to use the JRE of the platform execute the applets for me rather than writing the code for my Browser to interpret the class files.
    Thanks in Advance.

    You just need a custom class loader to bring these applets into your JVM.
    http://developer.java.sun.com/developer/onlineTraining/Security/Fundamentals/magercises/URLClassLoader/index.html
    Then you can use the methods of java.lang.Class to create an instance of such a class. As soon as you have it, you can just treat it as a regular Applet and invoke init(), stop() etc. appropriately.
    If you want to execute anything else than conventional Applets, you might consider reflection to find out about methods implemented:
    http://java.sun.com/docs/books/tutorial/reflect/index.html

  • How to protect the .class files from decompilers

    Hi all,
    I have developeed an application and I want it to be protected from the decompilers. The problem that I am facing now is that the .class files can be ripped by using the decompiling softwares.
    It will be great if any body cvan bail me out of this.
    Thanks
    kvmp

    Obfuscating your files is your best bet. This has been discussed to death, both here and on every other Java-related discussion site and newsgroup since about 1996; a Google search on "Java obfuscation" should help.
    You can also look here for an overview:
    http://mindprod.com/jglossobfuscator.html#OBFUSCATOR
    Grant

  • Protecting swf files from being decompiled

    At the end of the day, our flex apps are deployed as swf
    files which have the potential to be decomplied and thereby our
    intellectual properties lost. There are tools in the market which
    claim to secure the swf files from being decompiled. Are these
    tools live up to their claims? Is it worthwhile to spend money on
    these tools? Would the protected swf become harder to deployed? Any
    good products already available in this line? Please point out
    some. Thx.

    Most of the tools I have seen are geared towards extracting
    resources from swf's. I use one myself (eltima.com) for
    "harvesting" manufacturers content for my motorcycle dealers. They
    are authorized to use this content, but finding someone at Yamaha
    of Kawasaki or any of the majors who even knows where to find these
    resources is next to impossible. I have also used it to learn from
    by viewing scripts, but as you say, at the end of the day, I think
    the concepts and best practices are about the only thing worth
    taking away from others efforts, not the code.
    Unlocking a protected file can be done as well and I remember
    using a product over a year ago to get at the scripts within an swf
    (I wanted the URL's that pointed to media - it was legal for me to
    do this). It ran from the command line and output the scripts.
    There aren't too many of these types of programs to be found, but
    they exist.
    My personal opinion is that it's not worth the effort. My
    java classes can be decompiled and if someone wants to go to that
    trouble, more power to them. To my knowledge, there isn't anything
    out there yet that is perfect for backwards engineering an swf into
    an MXML file, but a competitor of FLASH Decompiler says that they
    can decompile Adobe 9 PLAYER swf's. For what it's worth, I plan on
    posting the majority of my code on my flexdev.org site once I get
    it established.
    For people who make components for sale, this could be an
    issue of stolen revenue if the decompilers get sophisticated enough
    to reverse engineer the swc into a usable MXML file. I would be
    against anyone who stole code for this purpose, for sure.

  • Protect jar file from unzip utility

    Hi
    I have an application in .jar file and I don't want that the client
    can extract or unzip and see the contents of my .jar file.But still the .jar file
    could run by mouse double click or java -jar command.
    Anyone can give me an idea how to do it.
    Thanks...

    If java can read it on your client's machine, the client can read it. There is no way to prevent this. Here's the general cycle:
    int protectionMode = chooseProtectionMode();
    boolean haveCustomers = true;
    while (haveCustomers)
      switch (protectionMode)
        case OBFUSCATE: 
          //You can obfuscate your code to make it (marginally) harder to
          //reverse-engineer.  If your client is really interested in your
          //code, this won't keep them from figuring out what it does.
          break;
        case ENCRYPT:
          // You can encrypt most of your class files, and build a
          // decrypting classloader, and build a framework that calls
          // the decrypting classloader to get at the rest of the jar. 
          // Of course, your client can just arrange to call your
          // classloader from their own, and write the (decrypted)
          // classfiles to disk, and then reverse engineer them.
          protectionMode = OBFUSCATE;
          break;
        case STATECHECK:
          // You can put some kind of check in your decrypting classloader
          // that calls System.exit() if it discovers it's being called in
          // such an unfriendly way.  Your client will take about 10 minutes
          // to find and remove the check.
          protectionMode = ENCRYPT;
          break;
        case REMOTE:
          // You can keep your code on your server and let the client run
          // something that talks to it.  The client will complain
          // vociferously, and refuse to use your app. 
          haveCustomers = false;
          break;
        default:
          // You can decide to stop stressing over something you can't
          // help, and write code that people will buy
      }(Sorry - in an odd mood, seen this question or one like it too often recently, not enough sleep...)

  • What is the best way to protect .class files on server?

    I've been working on my website project for quite some time, years in fact. Now I'm at the point where I'm looking into signing up with a web host provider and testing the site live.
    I have some questions and concerns though. My site is made up of Java Servlets and JSP pages.
    My foremost concern is protecting my code. Many suggest obfuscating. If I understand the process correctly, it involves making the code harder to decompile. I also understand that obfuscating isn't a guarantee in protecting code. If someone really wants to use the code, they'll figure out a way to.
    So are there any other options available to protect my code?? I would like to consider as many options as possible.
    Once it is on the web host server, anyone can have access to it. Hope this doesn't sound like a stupid question - Microsoft Word comes with the option to password protect files from being opened, is there not by now some way to implement the same sort of feature with files uploaded to a server?
    Your input is appreciated.

    ejp wrote:
    Once it is on the web host server, anyone can have access to it.That's not true. You're off on the wrong track before you even start. You need to acquire a proper understanding of a web server and its configuration. Your problem can be solved via correct configuration of the server. Nothing to do with obfuscation.So your telling me that once I've uploaded all my .class files and everything else to my host provider, that the people running the server do not have access to it? I find this hard to believe....
    What exactly would I be looking to configure on the server??? Please explain.

Maybe you are looking for

  • I can't open itunes on my HP laptop.  I keep getting the error message " You don't have the proper permissions to open this file".

    Hello- I can't open itunes on my HP laptop that uses Windows 7.  I keep getting the error message "you don't have the proper permissions to open this file".  I removed all Apple downloads and reinstalled itunes 10.6.3 windows 64-bit numerous times, b

  • PXI not showing up properly in MAX

    Hey everyone, I'm new to setting up remote systems in MAX and I'm having some difficulty.  I'm using all LabVIEW 2011 versions of software with FPGA and RT modules.  I'll start by listing the hardware I am using: PXI-1042 Chassis PXI-8110 Embeeded Co

  • How to restore from Time Machine onto an external drive

    Hi all, I am a backup freak, and I don't feel entirely safe with Time Machine taking care of backing up my system unless I can test every now and then that I would be able to do a full restore. I've had problems in the past with .Mac/MobileMe's Backu

  • Diaplay BLOB content (jpeg picture) in XML Publisher 5.6.3

    Hi Gurus, I am trying to include BLOB content (jpeg picture) in my RTF template. But the pdf output giving blank page. I am using following syntax in my picture form field. <fo:instream-foreign-object content-type="image/jpg" width="251.8pt" height="

  • Terminal won't launch or open at all?

    When I click on the Terminal app, it doesn't launch at all. It doesn't even show up on my dock. The icon for it is the default application icon as well, and I have no idea what to do. I can't reinstall OS X since I left the disk for it in another cou