• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Reflection assignment  RSS feed

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having problem with an assignment about Reflection API.
We are required to write a ClassReader residing in a directory which inspects any Class has been entered into that locale and prints out class members. The user will package a Demo Class into a Jar file to be entered into the resident directory. The ClassReader should be able to automatically detect the new Class once the Class is loaded into the directory.
I have no problem with writing the ClassReader itself. But I have no idea about how to enable the automatic detection. The instructor gave hints about using scripting. Unfortunately, I know very little about scripted language like JavaScript. Can someone tell me how to solve this problem using pure java? Thanks.
------------------
------------------------
Sun Certified Java Programmer
----------------------------------
 
Sheriff
Posts: 13454
222
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about setting up a low-priority thread that invokes File.list() every so often. If the list has changed since the previous call then you can check for a new Class. The rest is left as an exercise for the student...
Junilu
 
Tom Tang
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like a good idea. Many thanks.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you access the class in a JAR file dynamically?
Different JAR files are constantly added to the current
directory. This means the classpath is changing.
I tried System.setProperty() to set classpath and using
ClassLoader and It did't work.
Do you have any solution?
Thanks
Jimmy
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!