'Eclipse Java project build path using variables in linux
I have a Java project which refers external Jar file. It was referred via Java build path by clicking "add external Jar" and Jar file is in windows local drive. I am able to compile using my eclipse.
Now I have to build same Java application in my build server and hence I tried below mentioned different options. All the options are throwing me an error.
Setup :
- I am using Java 8. This Java is packaged by IBM tool called "IBM App connect". My code will use this Java application for build
- I have setup classpath in profile with Jar file location
- My build server is Linux where my Jar file is kept with chown as same login user and chmod as 755.
- I have set environment variable as well
export SOURCE_PATH=/home/someuser/sharedjars/
[someuser@ip-20-**-1**-1** ~]$ echo $SOURCE_PATH
/opt/IBM/app/sharedclasses
[someuser@ip-20-**-1**-1** ~]$ echo $CLASSPATH
/opt/IBM/ace-12.0.3.0/server/messages:/opt/IBM/ace-12.0.3.0/common/classes:/opt/IBM/ace-12.0.3.0/server/classes:/opt/IBM/ace-12.0.3.0/common/classes/IntegrationAPI.jar:/opt/IBM/ace-12.0.3.0/server/classes/brokerutil.jar:/var/mqsi/common/wsrr:/opt/IBM/app/sharedclasses
[someuser@ip-20-**-1**-1** ~]$ ls -ltr /opt/IBM/app/sharedclasses
total 280
-rwxr-xr-x 1 someuser mqbrkrs 284184 Jan 31 11:27 commons-codec-1.10.jar
I am getting error saying
Problem markers list from the workspace:
Problem 4: Resource - /someAppJava; Error message - The project cannot be built until build path errors are resolved.
Problem 5: Resource - /someAppJava; Error message - Unbound classpath variable: 'SOURCE_PATH/commons-codec-1.10.jar' in project 'someAppJava'.
I have went through some of the existing forums and tried but those answers are not working for me. Please show some light on my issue.
Tried below options.
Tried setting var in .classpath file as like below
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="var" path="SOURCE_PATH/commons-codec-1.10.jar"/> <classpathentry kind="con" path="com.ibm.etools.mft.uri.classpath.MBProjectReference"/> <classpathentry kind="output" path="bin"/></classpath>
We are getting workspace error when dependency project is Java application and Java application refers to the Jar files which is in its build path. Since build path for toolkit is in some developers directory. This directory not exists in build server.
As a solution , we included the Jar as part of Java applicaton. This results into bar file sized increased because this jar included in the bar file. It suppose not to be included in the bar file because these Jars will be kept in shared path.
Updated classpath file as like below.
<classpathentry kind="var" path="$SOURCE_PATH/commons-codec-1.10.jar"/>Updated classpath file as like below.
<classpathentry kind="var" path="${SOURCE_PATH}/commons-codec-1.10.jar"/>Updated classpath file as like below.
export SOURCE_PATH=/opt/IBM/app/sharedclasses/commons-codec-1.10.jar <classpathentry kind="var" path="$SOURCE_PATH"/>
- Updated classpath file as like below.
export SOURCE_PATH=/opt/IBM/app/sharedclasses/commons-codec-1.10.jar <classpathentry kind="var" path="SOURCE_PATH"/>
Got same error on all the above trial and error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
