get .class File object

Discussion in 'Plugin Development' started by RcExtract, Aug 17, 2018.

Thread Status:
Not open for further replies.
  1. Offline

    RcExtract

    I tried Test.class.getProtectedDomain().getSourceCode().getLocation() but it returns the jar location. I tried Test.class.getResource("Test.class"). It returns a correct location, but when i construct an input stream to the File object it throws FileNotFoundException strangely. I tried Test.class.getClassLoader().getResource("Test.class") and it returns null. Plz help.
     
  2. Offline

    timtower Moderator Moderator

  3. Offline

    RcExtract

    Practice
     
  4. Offline

    timtower Moderator Moderator

    Even with practice a goal is needed, a reason to do it.
    The jar is a zip. Unzip it.
     
  5. Offline

    RcExtract

    Isnt unzipping expensive? Also i never heard of this method. I think files within a zip can have their locations identified cuz i printed the resource (.class) location successfully but file not found...
     
  6. Offline

    timtower Moderator Moderator

    @RcExtract Do you care about expensive when fetching a class file that has no further use?
     
  7. Offline

    RcExtract

    I like ur quick response. Well i may use the getResource in my plugin, but i would like to keep it secret.
     
  8. Offline

    timtower Moderator Moderator

    Getting the class file is scetchy at least. Same for some other threads you made.
     
Thread Status:
Not open for further replies.

Share This Page