0

A coworker wrote a web piece in Java but he is no longer with us. I am not familiar with Java, but table names in our Application database, which are referenced in SQL scripts within the .class files, need to be updated to reflect software changes. I downloaded Java Decompiler so I can read the code, but I cannot save changes with this program. Is there anything I can do without learning Java?

7
  • 2
    asking for source didn't work? Commented Jul 31, 2014 at 18:03
  • 1
    ... and you don't have version control and the former coworker formatted the hard drive of his workstation before leaving the house. Commented Jul 31, 2014 at 18:08
  • its better not to do without knowing it Commented Jul 31, 2014 at 18:09
  • If something like PreparedStatement was used then you'll most likely have to rewrite the section of code. Commented Jul 31, 2014 at 18:10
  • If this is code developed inside the company and that belongs to the company, your coworker has to give your company the source code. Otherwise, what you are doing is illegal. Commented Jul 31, 2014 at 18:11

3 Answers 3

1

There is no way, you can update the content in .class file directly.

  1. save the decompiled code as .java file
  2. change your SQL scripts in that
  3. compile it again .. you will get the .class file with updated changes.
  4. replace the old class file with this one.
Sign up to request clarification or add additional context in comments.

Comments

0

Without the source you're going to be hurting. You could try using a java decompiler and seeing if you can extract the source and recompile it, but it is not going to be an easy task unless it's trivial java code. Unless you're just digging to see what it does, I'd get the code recompiling before I made any changes to it (since getting it recompiling is going to be the hard part).

FYI, all of this assumes the code is licenses in such a way that decompiling it is OK. Don't send me your lawyer bill if you're breaking a EULA (tongue in cheek, I doubt you'd actually get sued).

Comments

0

You have not told us what database you are using and is the only SQL TABLE names that needs to be changed to different name. If you only need to change table names, you can create a VIEW in mysql/oracle/sqlserver/postgresql/db2 that will be like an alias for the old table name. For example mysql:

CREATE VIEW table_name_in_java_class_file AS
SELECT * FROM your_updated_table_name

Since you decompiled class, you can see what table names it references and create a view named like that to point to your new table. But columns need to be the same, in your new table, unless you know for that that class doesn't care about the column types/order/etc. Most likely you will be better off with hiring someone part time to do this for you if you not familiar with Java or programming in general.

1 Comment

Thank you for your answer. I should have been more clear. Here is an example. In our application database for the last version of our ERP software, table itemcust housed all the information needed and referenced. In the newest version, table itemcust remains, but pricing information is separated into table itemcustprice. Also, the itemcustprice table contains effective dates (why it was implemented) and I will need to alter the statement to pull the information from the last effective date.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.