Why is the System.getProperty not working in eclipse + Java 8? -
so in run configuration in eclipse, picked main class main.java, in tab "program arguments" put testarg=sample.
in application's main method, a: system.out.println on:
args[0]system.getproperty("testarg")
the result args[0] testarg=sample, result system.getproperty("testarg") null.
what going on? using java 8 , eclipse kepler.
note:
when put in "vm arguments" box testarg=sample, , error :
error: not find or load main class testarg=sample`
system.getproperty() gets vm arguments specified -d, these typically used configure vm. argument 'program argument'.
see : what's difference between program arguments , vm arguments?
as using eclipse (depending on version); should able specify vm arguments , program arguments run configuration in same place under arguments tab:
- program arguments - passed args[] main method
- vm arguments - available through system.getproperty()

Comments
Post a Comment