Search code examples
javasystem-properties

How to add system property to exe file in java


I have a project in java, which i want to run only if the user is admin, for that I set system property to admin - -Duser=admin

I export my project to a jar and create its exe.

How can i set system property for exe file? How to verify if user is admin, easy in case of batch file but unable to do for exe file.

User admin does not mean windows admin user, i want to make certain people admin and use some specific features of my application.


Solution

  • While creating exe via launch4j , under JRE tab, we can define system properties in JVM Options as -Duser=admin

    This will be same as defining any system property in run configurations of eclipse.