Results 1 to 5 of 5
Thread: Can you help?
- 07-14-2009, 09:54 PM #1
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
Can you help?
Hi,
My question is this:
My work has given me a in use (working) file in which they want me to change the head office address. The file .class so obvioulsy it is a compiled java file thus its source can only be read using a decompiler that I have done.
I am using DJ Java Decomipler and have opened the file and have made the change required. It was a simple change of address.
The problem now is how to save the change? I can save the file as .java or .jad. And if I try to compile the .java file I get the 2 errors which I am not sure.
Isnt there any way where I can simply save it back to .class?
What should I do? I want to save the change.
Thanks.
- 07-15-2009, 05:56 AM #2
There is a lot wrong with your code. For starters, try this code by itself and see how that works for you. Then go from there:
public static void main(){
int age = enterAge();
JOptionPane.showMessageDialog(null, "You are " + age + " years old.");
}
public static int enterAge(){
return Integer.parseInt(JOptionPane.showInputDialog("Your Age?"));
}
Also, you are making everything static. This can get messy, as you cannot then make class variables easily. I prefer to do it this way:
class SomeClass{
public static void main(String[] args){
new SomeClass();
}
public SomeClass(){
//This is the constructor
int someInt = getAnotherInt();
}
public int getAnotherInt(){
return 5;
}
I hope you get the idea there. Lastly,
age = enterAge(/*int*/age);
That line is a mess. You need to declare type before you can assign, and you NEVER declare type inside a parameter, and that method [enterAge()] doesn't even take any parameters to begin with. It should look more like this:
int age = enterAge();
Good Luck
- 07-15-2009, 10:20 AM #3
Member
- Join Date
- Jul 2009
- Posts
- 4
- Rep Power
- 0
whats your post got to do with my question??
- 07-15-2009, 12:04 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Oh good...it's not just me then. I thought I was going mad for a second there!
Anyway, on your topic, um...you really don't have the source code for this project? That's not a Good Thing...and decompiling and then recompiling just smacks of a truly dreadful hack. This is production code?
Anyway, you need to compile the new java file, for which you need a java compiler.
-


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks