Results 1 to 10 of 10
  1. #1
    JavaNoob84 is offline Member
    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0

    Default Editing .class files

    I have a couple of executable jar files that are filled with a bunch of .class files. These 2 jars are included as libraries in the java build path of the project.
    I want to edit those .class files inside those jars. Even after I unchecked read only, I still cannot edit them in Eclipse. I can open them, but nothing happens when I type. Is it possible to edit those somehow?

    Thanks.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Editing .class files

    What do you expect to achieve by editing the bytecode?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JavaNoob84 is offline Member
    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0

    Default Re: Editing .class files

    I want to change a bunch of JOGL 1 import statements to JOGL 2.0 equivalents and see if the code still works.
    I mean I see all the code inside each .class in eclipse, just can't change it.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Editing .class files

    Import statements don't exist in a .class file. They are just semantic sugar that saves you the trouble of having to specify the fully qualified class name every time it is used.

    Whatever you're seeing, it's not imports.

    If JOGL 2.0 is 100% backward compatible with earlier versions, I think you should be able to change which version your program uses by manipulating their availability on the classpath.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    JavaNoob84 is offline Member
    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0

    Default Re: Editing .class files

    Yeah I sort of figured it took some sort of decompiler and wasn't about to mess this that since I have the source files for those jars. JOGL 2.0 is not backward compatible though. Anyone has ever gone through an exercise of getting through that?

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Editing .class files

    If you have the source files, why are you even thinking about editing .class files?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    JavaNoob84 is offline Member
    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0

    Default Re: Editing .class files

    Didn't know where they were at the time.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: Editing .class files

    Ah, ok. Problem solved then?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  9. #9
    JavaNoob84 is offline Member
    Join Date
    Nov 2011
    Posts
    14
    Rep Power
    0

    Default Re: Editing .class files

    I'd say so. Thanks.

  10. #10
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,528
    Blog Entries
    7
    Rep Power
    20

    Default Re: Editing .class files

    Eclipse is quite clever when it comes to showing a .class file to a user: if it can find the source of that file it shows the source as a read only file; if it can't find any source, it partly decompiles the .class file (as javap -c would) and shows that, also as a read only file.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Editing text files
    By NickBru in forum New To Java
    Replies: 4
    Last Post: 12-05-2010, 06:27 PM
  2. *.class-files
    By artemff in forum New To Java
    Replies: 3
    Last Post: 12-31-2009, 08:38 PM
  3. conversion of java .class files to .java files
    By kotturupraveen in forum New To Java
    Replies: 2
    Last Post: 06-09-2008, 12:58 PM
  4. 'class' and 'jar' files
    By ai_2007 in forum Advanced Java
    Replies: 1
    Last Post: 06-29-2007, 03:11 PM

Posting Permissions

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