I have a python script that downloads the latest svn build, then converts the project to an aspectj project and adds the necessary libraries , except for the Aspectj Runtime Library. I have my script trying to add the library in to the .classpath file like so: <classpathentry exported="true" kind="con" path="/Users/rovimacmini/.m2/repository/org/aspectj/aspectjrt/1.8.0/aspectjrt-1.8.0.jar"/> but I get an error that the aspectjrt.jar isn't in the classpath. Does anyone know how I can add it via the .classpath file so that my java build path has the AspectJ Runtime Library in it like so:
I suggest you manually create an AspectJ project in Eclipse and just look at how Eclipse does it.
.project needs an 'ajbuilder' and an 'ajnature':
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AspectJ_Project</name>
<comment></comment>
<projects></projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.ajdt.core.ajbuilder</name>
<arguments></arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.ajdt.ui.ajnature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
.classpath needs a container ("con") classpath entry for the AspectJ runtime:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Update: I also tried replacing the container entry provided by AJDT by a direct reference to a manually installed library in my local file system like this:
<classpathentry kind="lib" path="C:/Program Files/Java/AspectJ/lib/aspectjrt.jar"/>
It works nicely. So in this case it is not con, but lib type. In my experience it also is not necessary to set the exported property, you can just skip that one.
Related
I am using Eclipse IDE with selenium, testng, Java on Ubuntu machine to automate test cases.
I committed a fresh new Project into Git and when on another machine by doing a git clone and importing the project. src folder which is source folder appears to be just a folder including the packages inside src folders.
How can i configure the project in such a way where after git clone and importing the project the src folders are intact and they appear to be src folders instead just folders.
Ecl;ispe IDE verison
Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components)
Version: 2021-06 (4.20.0)
Build id: 20210612-2011
.Project content
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SeleniumTests</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
.classpath content
<?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/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
It is a multi maven project
I'm using Eclipse version 2019-03 (4.11.0) and I have a project with a big red exclamation mark to the left of the project name. I am not using any dependency management tool, I am managing my dependencies myself manually. The Problems view is telling me that my project is missing a required library, but that jar file is no longer in my list of dependencies for the project (I replaced it with an upgraded version recently, and the problem has existed since then). In case this was a GUI issue I checked the .classpath file for the project in a text editor and it's not listed there. I've also tried cleaning and re-building the project.
This problem is masking compile error and warning icons over the source files in my project. Is there something obvious I've missed? (before I attempt to recreate the project from scratch).
The error listed under the Problems view is:
Project 'MyProject' is missing required library: '/home/me/eclipse-workspaces/work/MyProject/xyz.jar'
The Location is Build Path and the Type is Build Path Problem.
Here's an edited version with the relevant stuff in my .classpath (the supposed missing jar is NOT listed in this file):
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="/home/me/eclipse-workspaces/work/MyProject/somelib.jar"/>
<classpathentry kind="lib" path="/home/me/eclipse-workspaces/work/MyProject/anotherlib.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Enki-Utils"/>
<classpathentry kind="output" path="bin"/>
</classpath>
The only other Eclipse related file in my project root directory is .project:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MyProject</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
The solution for me was to close and re-open the project (without restarting Eclipse) which must have flushed out some stale cache. The accepted answer for this question got it for me (with some other possible solutions if that doesn't work).
Currently I'm trying to write a tool for migration from Eclipse IDE to Intellij Idea specifically for my project.
For now, the main question is how and where Eclipse store project information (i.e. libraries, dependencies between app modules and so on) internally.
P.S.
The Intellij's migration tool does not work for my project.
Update:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry excluding="generated/" kind="src" path="src"/>
<classpathentry kind="src" path="src/"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Everything that eclipse keeps on your project is stored in the .settings folder (containing a.o. .project and .classpath).
But unless you have some very specific setup you should be able to import your project into IntelliJ without any hassle. Even if it's not, I would expect that setting up the project manually in IntelliJ will be a lot faster than writing a tool for it.
I have a maven (3.0.4) multi-module build project which works on command line perfect.
mvn clean package
build successful.
I've tried to import that project into Eclipse
with m2e 1.0.
but after it's ready i can't see a package folder nor the icon for src-folders (like src/main/java etc).
But i would have expected to see something like the following:
Does someone has a hint what problem might be? Or ideas where to look for?
Update
After boiling this down it might be caused by using a Java 1.7. compiler which i have configurate like the following:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<executable>C:/Programme/Java/jdk1.7.0_05/bin/javac</executable>
<fork>true</fork>
</configuration>
</plugin>
...
Someone with experience in this area?
It looks like your project doesn't have a Java nature. You can change this by right-clicking the project and going to
Properties -> Project Facets -> Convert to faceted form
From there you can add a Java facet, which should do the job. I often find with this sort of thing that it's easier to just edit Eclipse's .project and .classpath files manually (make sure to back them up before you do though!) instead. You'll probably want to check that your project's .project file includes something like this:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
...
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Then make sure your .classpath looks something like this:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
...
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Once you've got all this stuff ready to go, update your project configuration like Michal said and refresh.
After long fiddling around i've found the problem which solves it for me:
I had a wrong lifecycle mapping for the maven-compiler-plugin (2.5.1) in my configuration which caused the problems. After removing it it works as expected no need to change the facets manually just import the project and it works.
In your eclipse, it might be pointing to JRE instead of JDK.
Go to window->preference->java->Installed JRE. Add JDK here, and set it to default.
You may need to restart eclipse.
I am trying import a project from Perforce workspace in Eclipse. It is importing it (fetching the files into java package hierarchy) but the problem is it is not importing as "Java project". so i can't edit the "Build path" or there is no classpath or something.
Any idea?
You need to make sure to put Eclipse metadata files into your source control system. All files starting with . in the project root along with entire .settings directory need to get checked in along with your source. If you don't do that, Eclipse will loose all knowledge of the type of projects that it is and how it supposed to be configured.
If your Project in Perforce do not contain files of regular Eclipse java projects you can create another project with Java Nature. Keep Project empty.
File > New > Java Project
It will create for you following files.
.classpath
.project
.settings/org.eclipse.jdt.core.prefs
With this empty project by default your source folder is set to "src".
Now you have to copy first two files mentioned above to your Perforce workspace directory. Close and reopen project.
If you still have issues please check file .project. It should contain Nature section.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Dev-Project_03_04_2016</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Now Check your .classpath File. Since you copied it from blank project it contains something like:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
You need to remove this default default "src" folder and add your source folders, of course if you wont do development in eclipse you do not need all this. If you did everything correctly, andded also JUnit Nature you wil get something as follows:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="bb/apps/911access-zip/components/911emergencydriver-ejb/src/main/java"/>
<classpathentry kind="src" path="bb/apps/911access-zip/components/911accessmodel-ejb/src/main/java"/>
<classpathentry kind="src" path="bb/apps/911access-zip/components/911accessplugin-ejb/src/main/java"/>
<classpathentry kind="src" path="bb/apps/911access-zip/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="bin"/>
</classpath>