Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to read a class file from jar  RSS feed

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can some body tell me how can I read the class file(containing main method) from a jar file ?


Thanks,

Kousik
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you just want to execute a program from a jar file then you can use "java -cp myjarfile.jar packagename.ClassName" (add parameters if needed). If you want to load the class into memory from another program you should probably look at the java.util.jar package.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!