I've a java project in the eclipse which has a .classpath file as shown below:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
<classpathentry kind="src" path="src/generated/java"/>
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
.......
<classpathentry kind="output" path="target/classes"/>
How does this file gets generated? Can I edit this file?
I want a certificate file to be added to the project in path target/test-classes. Where do I configure that?
My understanding is the target/test-classes folder gets generated after the mvn clean install. So I think there should be some place where I can configure what all I need in the target folder. Do I need to configure it in pom.xml ?
The .classpath file reflects the content of all the settings that you apply manually to your BUILD PATH setup within your project.
In other words: while using the eclipse UI to setup the BUILD PATH, all that information goes into the .classpath file.
And it is perfectly possible to stop eclipse and make changes to that file within your preferred editor; then restart eclipse, probably do a full refresh; and (unless you messed up) the changes should be visible when opening your BUILD PATH settings again.
Related
I have downloaded the jdt-ls as language server and configured as described here https://lsp.readthedocs.io/en/latest/#java
My project has source code which is in 'src/main' but sublime text (or jdt-ls) seems to assume that the source code lies in the root folder, i.e. every java file has a "wrong" package name. Is there a configuration for projects?
I found the solution. In the root of the project there must exist a .classpath file. Here is my file for example:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/main" output="bin/src/main"/>
<classpathentry kind="src" path="src/test" output="bin/src/test"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
...
</classpath>
We are building a Java tool that runs on both Windows and Linux. The project is built in Eclipse. In the project we include The Standard Widget Toolkit (swt.jar). There are no common swt.jar file for both Windows and Linux, so we have to use different files, and this is what is causing the problem. Some developers are building on Windows and some on Linux, and to make it work the developer have to change the swt file to match the current building environment and this has to be done in a number of places. This is one of the .classpath files:
<?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 combineaccessrules="false" kind="src" path="/logviewer_common"/>
<classpathentry kind="lib" path="/logviewer/swt/linux_x64/swt.jar"/>
<classpathentry kind="con" path="SWT_CONTAINER/PLATFORM"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Is there a way to add a condition that if I am building on Windows the file /logviewer/swt/win64/swt.jar is included and if I am building on Linux instead the file /logviewer/swt/linux_x64/swt.jar is included?
I have been trying to read and understand the XML tags and found that there is an <os> tag where one can specify Windows or Linux(unix), but it seems like I am not clever enough to understand if or how this can be used.
It is configured and built with Ant.
Would be very grateful for some help!
I am getting this error in some projects in my workspace.
I have tried using Luna and Juno version of eclipse but there are errors is still in there in both versions of eclipse
Content of .classpath file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="folder1"/>
<classpathentry kind="src" path="folder2"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/WebSphere v6.1 JRE"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/com.ibm.ws.ast.st.runtime.runtimeTarget.v61/was.base.v61"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/hibernate"/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/log4j"/>
<classpathentry kind="src" path="/ProjectB"/>
<classpathentry kind="src" path="/ProjectC"/>
<classpathentry combineaccessrules="false" kind="src" path="/ProjectD"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="folder2"/>
</classpath>
There are no build path errors in ProjectB, ProjectC, ProjectD
There is no proper solution
You can change that issue from error to warning in project preferences.
Under Project Properties->Java Compiler->Building
Make Sure Enable Project Specific settings is checked, Under Build Path Problems,
change Output location overlaps source location from Error to Warning/Ignore.
You can also find some related discussion on the issue over here
I did get a solution on this issue:
There is a specification of which particular folder cannot be output at the time of creating the project. I renamed that folder to .old closing eclipse and , also tried deleting it as it was a sample folder.
If its a folder which is not that important rename that folder after closing eclipse and retry.
This would fix the problem.
For me the solution was to add this line
org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=ignore
to .settings/org.eclipse.jdt.core.prefs
You have to remove that the distinct source folder 'folder2' from the src path
GO to project build path
go to source tab
select the folder2 src entry
remove it
I would like to use an Eclipse classpath variable to resolve the attached source JAR file for a library in my classpath. This is the contents of my current ".classpath" file in Elcipse (Indigo):
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="lib/ApacheCommons/commons-logging.jar"/>
<classpathentry exported="true" kind="lib" path="lib/Spring-WS/spring-ws-1.5.8-all.jar"/>
<!-- [other entries] -->
<classpathentry kind="output" path="bin"/>
</classpath>
When I now add a source JAR file for "spring-ws-1.5.8-all.jar", the ".classpath" files contents is:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib" path="lib/ApacheCommons/commons-logging.jar"/>
<classpathentry exported="true" kind="lib" path="lib/Spring-WS/spring-ws-1.5.8-all.jar"
sourcepath="D:/dev/sources/spring-ws-1.5.8-sources.jar"/>
<!-- [other entries] -->
<classpathentry kind="output" path="bin"/>
</classpath>
As you can see, Eclipse added the "sourcepath" attribute to the "classpathentry" element with an absolute path.
Now my idea is to replace the absolute path with the classpath variable "SOURCE_PATH", which is correctly set to "D:/dev/sources".
(Please, don't ask why we have this setup or suggest we must change it; it is an old project and we are unfortunately not able/allowed to change the build structure).
I tried
sourcepath="SOURCE_PATH/spring-ws-1.5.8-sources.jar"
as well as
sourcepath="${SOURCE_PATH}/spring-ws-1.5.8-sources.jar"
but both variants do not work.
I seems, that I either use the wrong syntax or I don't understand the concept of classpath variables. Maybe the classpath variable can't be used for the "sourcepath" attribute?
Thanks a lot for your help!
I might not understand your question completely but it sounds like you added your jar file with an absolute path to begin with. Instead add it with a classpath variable.
Use the Project properties, select Java Build Path option. Then click on the Libraries tab. Then Add Variable.... If you haven't created your SOURCE_PATH classpath variable yet, you can do it from here by clicking the Configure Variables... button (just a shortcut to the proper workspace preference setting). Once configured you should see your SOURCE_PATH class path variable in the box at the top. You can click on it extend to Extend... it to a subfolder or a jar file.
Using Tod's answer above, if you have lots of jars in lots of projects, you may find it easier to edit the .classpath files directly. Using a Java Build Path variable in .classpath changes the reference from:
<classpathentry kind="lib" path="/full/pathTo/Jar.jar"/>
to:
<classpathentry kind="var" path="NEW_PATH_VARIABLE/Jar.jar"/>
You could use a symbolic link. Windows also supports paths starting with /. This is drive dependent. Try cd / on the Command Prompt to verify.
I have a java project. The working folder from someone else's Eclipse project (It was a Repast Simphony project I think).
In my eclipse I created a new Java project and told it to use the existing code. So it seems to have brought in all the code.
However after loading the project I get this error:
Project 'My Project' is missing required Java project: 'Weka 3-7'
It has a .classpath file with these contents:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/Weka-3-7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
What I've tried so far:
I installed Weka 3-7. Then I updated the .classpath file to say the following and reloaded the project.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="C|/Program Files/Weka-3-7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
But now I get the error message:
Project 'My Project' is missing required source folder: 'C|/Program Files/Weka-3-7'
Please help. I'm stuck.
You want to use the context menu: My Project::(right mouse click)::Build Path::Configure Build path. This gives you the option to add/remove projects, Jars, source folders etc., what erver you need to provide those classes that your project references. You can get the same effect by hacking the .classpath manually, but you have to know very well what you're doing. Always use the frontend unless it absolutely can't do what you need.