R Vicky wrote:@Rob, if I remove the static from @Autowired, it gives "Cannot make a static reference to the non-static field obj"
You need to:
* Create a Spring context.
* Get an instance of MainClass from the context.
* Access the instance's field.
I'm not sure if your KeyLogger can actually be auto-wired. It's not a Spring bean, and even if it were, it does not have a constructor that Spring can call. For each bean constructor, Spring must be able to find proper values for the parameters. Either because they are annotated (e.g. @Value), or because it's another Spring bean.
How are you even planning on creating KeyLogger instances?