Results 1 to 5 of 5

Thread: Can you help?

  1. #1
    pinguxxx is offline Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default 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.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    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

  3. #3
    pinguxxx is offline Member
    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    Default

    whats your post got to do with my question??

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default

    Quote Originally Posted by pinguxxx View Post
    whats your post got to do with my question??
    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.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I'd recommend that you find the creator/distributor of the code and get the source. Otherwise you're playing with fire with easy chance of things blowing up on you and possibly going against copyright and perhaps other laws.

Posting Permissions

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