View Full Version : how to protect code to avoid other ppl edit it?
nicky_85
02-21-2009, 06:53 AM
i jz wanna know how to protect code so that other ppl cant edit it?thx
Fou-Lu
02-21-2009, 07:17 AM
There is no such way.
Even C/C++ programs can be edited, it just takes more work. Java is compiled to bytecode, so its a level above. Its not easy to edit, but its not extremely difficult either.
When it comes to java, the best you can do is provide only the java classes jar, and remove the source code. That will make it harder, but not impossible.
Since you're not showing any code or anything, I question if this is actually java and not javascript. Javascript can only be encoded with replacement characters, the browser still needs to interpret it since it is executed on the client side. If its java, the only thing you can do is to create only thin client style applications that connect to a central program located on a remote server with RMI, web services, or other remote handling. That helps to protect you're business and data handling.
nicky_85
02-21-2009, 08:02 AM
im jz a java beginner, i plan 2 use a simple program into my fren business. my fren is a used car seller.the code as below:
import java.util.*;
class calcMonthPayment{
public static void main (String [] args){
Scanner s = new Scanner (System.in);
System.out.print("please enter loan amoumt : ");
double la = s.nextDouble();
System.out.print("please enter number of years : ");
int year = s.nextInt();
System.out.print("please enter interest rate : ");
double ir = s.nextDouble();
double total_loan=la + (ir*la/100);
double month=total_loan / (year*12);
System.out.printf("the monthly payment is : %.2f" ,month);
System.out.print("\n");
}
}
actualy the only way i know if i wan 2 use tis program into his business is :
install jcreator,then run the program. in order to run the program, 1st hv 2 open the code,but if he accidently delete o edit d code,then d program cannot run.
is there any suggestion for me?
Fou-Lu
02-21-2009, 02:20 PM
I don't understand you're question.
If you jar the file up, when you double click or execute it on the command line it will run the main method of the class targeted by the manifest.
There is no reason to provide the source code, a working application whether it be a GUI or CLI based app is already compiled into byte code - the *.class files.
Old Pedant
02-22-2009, 12:33 AM
Besides, if that's REALLY what you are wanting to do, it would be better to just use JavaScript and create a simple HTML web page.
And on top of that, your caculations are all wrong! That is *NOT* how interest rates are used/calculated! That's way too simple.
http://www.juncojunction.com/juncojunction/5k/LoanCalculator.html
Why do I get the feeling this is really homework???
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.