Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Getting source code from .jar file

  1. #1
    Join Date
    Jul 2009
    Location
    UK
    Beans
    222
    Distro
    Ubuntu

    Getting source code from .jar file

    Hello people, I have created a game in Java and I have also created its executable .jar file in order to be able to send it to people to test it themselves..

    My question is if it is possible for them to get the source code from the .jar file which is something I do not desire after all the effort I have placed into it.. Thnx

  2. #2
    Join Date
    May 2006
    Location
    Amsterdam
    Beans
    1,731
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Getting source code from .jar file

    A jar file is basicly a zip file, so getting to the .class files should be easy;

    jar -xf myApp.jar

    Then you have all the .class files, and you can use jad ( http://www.varaneckas.com/jad ) to decompile the .class files into source code.

    Please be aware that the source code now has no comments and is harder to reda due to cryptic names ala public function functionA(String stringA) etc etc. But at least you can have a peak at the code.

    It saved my *** once in college when I removed all my source code and only had my compiled .class files. Best of luck!
    Upgrade Ubuntu | Upgrade unsupported Ubuntu versions | Always backup | Howto upgrade flash
    Minimal CD install | Remove old kernels | My blog | Linux user #462801 | Conscience doth make cowards of us all. -- Shakespeare

  3. #3
    Join Date
    Jul 2009
    Location
    UK
    Beans
    222
    Distro
    Ubuntu

    Re: Getting source code from .jar file

    so is there another way to distribute the java program in order not to be able for the receiver to get its source code?

  4. #4
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Getting source code from .jar file

    Quote Originally Posted by hyperAura View Post
    so is there another way to distribute the java program in order not to be able for the receiver to get its source code?
    Even natively compiled code can be disassembled. Ok, the resulting code isn't trivial to read, but it can be read by a trained eye. There's nothing such as complete "source security" and no reason for it either: You can't stop an expert from getting your source whatever you do to prevent it, and will you bother about the average end user that just wants your program to work?

    No, encryption doesn't work because in order to have the application running, it'll need an intermediate layer that decrypts it...

  5. #5
    Join Date
    Jul 2009
    Location
    UK
    Beans
    222
    Distro
    Ubuntu

    Re: Getting source code from .jar file

    in my case this is not so important but I was just looking a bit more deeper on this..

    so for example if I want to sell some software the only way to force the buyer is by showing the features of the program face to face or sending him a demo program with limited features.. is that correct?

  6. #6
    Join Date
    Apr 2006
    Beans
    800
    Distro
    Lubuntu 12.04 Precise Pangolin

    Re: Getting source code from .jar file

    I agree with nvteighen, there is no way you can protect your code from a person who really sets his mind to get the source.
    Usually you obfuscate the code with proguard or similiar obfuscator and leave it to that.
    See http://developers.sun.com/mobility/m...ips/midletsize

    But I am no believer in hiding source at all costs either.
    I think it can be more profitable in the long run opening up your code, inviting other programmers to join you in making the application better (or game or whatever you're developing).

  7. #7
    Join Date
    Apr 2007
    Location
    (X,Y,Z) = (0,0,0)
    Beans
    3,715

    Re: Getting source code from .jar file

    Quote Originally Posted by hyperAura View Post
    so for example if I want to sell some software the only way to force the buyer is by showing the features of the program face to face or sending him a demo program with limited features.. is that correct?
    Nope... there's a much smarter model which is Red Hat's: Sell services, not code. This means, ok, you can get Red Hat from anywhere because it's Free Software and people are allowed to redistribute it either for free or not. But, only buying it at the Red Hat's official website will give you access to their own official support.

  8. #8
    Join Date
    Jul 2009
    Location
    UK
    Beans
    222
    Distro
    Ubuntu

    Re: Getting source code from .jar file

    cool, thnx for your replies.. well im not against open source but atm im at uni and i hate it when other people copy my code and get the marks without even working for it..

  9. #9
    Join Date
    Jul 2008
    Location
    Athens, Georgia
    Beans
    228

    Re: Getting source code from .jar file

    I might be in error, but I believe that Java's licensing requires you to make the source code available for any program you distribute. Maybe check your license?

  10. #10
    Join Date
    Aug 2006
    Location
    60°27'48"N 24°48'18"E
    Beans
    3,458

    Re: Getting source code from .jar file

    Quote Originally Posted by HotCupOfJava View Post
    I might be in error, but I believe that Java's licensing requires you to make the source code available for any program you distribute. Maybe check your license?
    Umm, no. That's wrong
    LambdaGrok. | #ubuntu-programming on FreeNode

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •