Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1045

groovy does not ignore global CLASSPATH even if -cp is specified on command line

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.0-JSR-3
    • 1.0-RC-1
    • None
    • None
    • groovy jsr03, jdk142_09

    Description

      groovy does not ignore global CLASSPATH even if -cp is specified on command line. Try this:

      C:\Temp>set CLASSPATH=foo

      C:\Temp>groovy -cp bar -e "println System.getProperty('java.class.path')"
      C:\programs\groovy-1.0-jsr-03\lib\classworlds-1.1-alpha-2-SNAPSHOT-NO-SYSTEM-EXIT.jar;foo;bar;.

      (foo should not appear)

      This is how java interpreter works - if you specify -cp / -classpath, the contents of CLASSPATH environment variable is ignored.

      I tried to do a unit test case out of this, but for some reason I was unable to get the output of another groovy process from groovy, e.g.

      def command = "groovy.bat -e \"println 'heiiii'\""

      def p = Runtime.runtime.exec(command) //, envp)
      def text = p.text
      // I would assume that text now refers to 'heii', but it is empty. I tried including p.waitFor() but to no avail.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            antti.karanta@napa.fi Antti Karanta
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: