title: Setting system properties in Groovy
body: <p><strong>Please note:</strong> Although I mention Swing and MacOS here, this question has nothing to do with either of them: I'm just providing them as a concrete example of what I'm trying to do.</p>
  
  <hr>
  
  <p>I'm trying to set a system property the groovy way. If you are developing a Swing app on a Mac, it is common practice to set the following system property so that your Swing app's menu looks the same as typical Mac apps:</p>
  
  <pre><code>System.setProperty("apple.laf.useScreenMenuBar", "true")
  </code></pre>
  
  <p>When I call that inside my <code>main</code> method, it has the desired effect (the menu bar gets pulled off of the <code>JFrame</code> and is pinned to the top of the screen).</p>
  
  <p>But when I go to try and make that call groovier:</p>
  
  <pre><code>System.properties['apple.laf.useScreenMenuBar', 'true']
  </code></pre>
  
  <p>it doesn't work. No exceptions, it just stops working and doesn't have the desired effect in the UI. <strong>Why, and what can I do to fix it?</strong></p>