Hi Devs,

I need to get the *Maven Home* value to execute maven goal eclipse:eclipse
for a created project. I tried to use *java.lang.System* class to retrieve
it by executing following code. But Maven Home in not listed in there
either properties or process environment.

if (System.getenv("M2_HOME") != null) {
            return System.getenv("M2_HOME");
        } else if (System.getenv("MAVEN_HOME") != null) {
            return System.getenv("MAVEN_HOME");
        } else if (System.getenv("M3_HOME") != null) {
            return System.getenv("M3_HOME");
        } else if (System.getProperty("maven.home") != null) {
            return System.getProperty("maven.home");
        } else {
            log.error("Maven Home variable value is not found in system
properties");
            throw new IllegalStateException("Maven Home variable is not set
");
        }

Maven is correctly installed in the system and following is the result when
I run "mvn --version"

nuwan@nuwan-ThinkPad-T540p:~$ mvn --version
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1;
2014-12-14T22:59:23+05:30)
Maven home: /usr/local/apache-maven-3.2.5
Java version: 1.8.0_66, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-68-generic", arch: "amd64", family:
"unix"

I have also had edit the .bashrc file by adding following lines.

export M2_HOME=/usr/local/apache-maven-3.2.5
export M2=$M2_HOME/bin
export PATH=$M2/bin:$PATH

But still I can't read M2_HOME from java.lang.System class.

Any help would be hugely appreciated.

Thanks,
Nuwan

-- 
----------------------------------------------------------

*Nuwan Chamara Pallewela*


*Software Engineer*

*WSO2, Inc. *http://wso2.com
*lean . enterprise . middleware*

Email   *[email protected] <[email protected]>*
Mobile  *+94719079739@*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to