Reputation: 27241
I have some java code that I want to share with some classmates however I do not want to share the source with them.
What is the standard method to provide someone with a Java executable that they can use but they cannot see the source.
Not sure if this is relevant but the code that I will be giving them will be run on android.
Upvotes: 0
Views: 635
Reputation: 193814
It depends on what you mean by "they can use".
If you just want them to be able to run your application on their phones (or emulators) you can give them an .apk
file, which is the standard format for Android Applications. The easiest way to produce an .apk
is to use the Android Development Tools (ADT) plugin for Eclipse. Otherwise you'll have to use the aapt
command.
If you want to allow them to add your classes to their applications you'll have to give them a .jar
file containing your compiled .class
files. However, it is possible to turn .class
files back into .java
files using a decompiler so you if you really don't want them to see your code you may be stuck.
There are tools - known as obfuscators - which make the decompiling process harder, but personally I wouldn't bother with them here as they also make debugging harder too.
It won't be possible for anyone to turn your .apk
back into source. Android uses a different Virtual Machine to standard Java and so has .dex
files with Dalvik bytecode rather than .class
files with JVM bytecode, and currently there are no tools that turn .dex
files back in to .java
source files.
Upvotes: 2
Reputation:
Android doesn't use the Java runtime. I only uses Java as a source language, it runs a custom runtime with a custom bytecode format. You can decompile the .dex byte code, but not to Java source code, at least not at the time of this post.
Upvotes: 1
Reputation: 81154
Package only the class files into a .jar file and don't give them the source.
Edit: Android has its own way of packaging applications, I would suggest using it.
Upvotes: 1