I have a classpath in my project there is two reference kind one is src one is con. con kind referenced jars is missing in my project. What is difference between these two reference kind and.
Here my .classpath file
1 <?xml version="1.0" encoding="UTF-8"?>
2 <classpath>
3 <classpathentry kind="src" path="src"/>
4 <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
6 ....
7 </classpath>
con is a container such as the JRE files or the required plug-ins list. src is a source files folder path. There is also output for the output binaries and a some others for required projects, variables and libraries.
Related
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 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.
I have set of ten to twelve native java projects checked out from svn. Eventually I am considering to convert all the code into groovy. I am only concentrating on these two steps first:
1) Convert java projects to Groovy projects
2) Change the extensions of all the 10,000 odd files in all the projects to .groovy.
So I want to know if eclipse can provide me some help with these two steps (via UI) without me having to change all the .classpath entries or .project entries.
PS: I already have the groovy plugin installed
Are the java projects also Maven projects? That creates a bit more confusion, but is workable. You should be able start by editing the .classpath
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry exported="true" kind="con" path="GROOVY_SUPPORT"/>
<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/someDirectory"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
This is for a Maven and Groovy project. You can leave out the Maven line if it is not needed. Eclipse doesn't seem to like Maven+Groovy projects, so you will have to fix the .classpath again after you import it, but it won't change it again after that.
I'd recommend using a batch file for the renames (or a C# program, if you have VS installed, too).
I found this example: https://superuser.com/questions/205083/which-command-can-i-use-to-recursively-rename-or-move-a-file-in-windows
For loops are a bit odd in batch files, but they work nicely.
I think that would get you going. Start with the smallest project, of course!
Here is my .classpath file, after I have added two more external jars (org.restlet.ext.simple.jar and org.simpleframework.jar):
<?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.6"/>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.jackson.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.ssl.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.restlet.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/api"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.jsslutils_1.0/org.jsslutils.jar"/>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.core.jar"/>
<classpathentry kind="lib" path="../3rd_party/restlet-jse-2.0.10/lib/org.codehaus.jackson_1.4/org.codehaus.jackson.mapper.jar"/>
<classpathentry kind="lib" path="../3rd_party/guice-3.0/aopalliance.jar"/>
<classpathentry kind="lib" path="../3rd_party/guice-3.0/guice-3.0.jar"/>
<classpathentry kind="lib" path="../3rd_party/guice-3.0/javax.inject.jar"/>
<classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.restlet.ext.simple.jar" sourcepath="C:/Program Files/Java/restlet-jse-2.0.10/src">
<attributes>
<attribute name="javadoc_location" value="file:/C:/Program Files/Java/restlet-jse-2.0.10/docs/ext/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="C:/dev/poc/3rd_party/restlet-jse-2.0.10/lib/org.simpleframework_4.1/org.simpleframework.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Notice that they have been added with absolute paths, unlike other entries which are with relative ones, but only because I manually edit this file each time new external jars are added.
My question is can I somehow tell Eclipse to use relative paths of newly added external jars?
Thanks.
One solution is to not use external jars, but to put your jars into a project, and then use Add Jar(s) instead of Add External Jar(s).
This makes sense from the point of view of source control, you can add/remove dependencies as you need them. It also means that when you update one jar for a separate project, it'll not affect this one.
We've done this in the past, we had a single project which contained all of the jars, which were referred to in the build paths of other projects.
But now we use maven, so we don't need to do that any more.
In eclipse, right-click the project, choose Properties, then Java Build Path, Libraries tab and select "Add Jars"... this will add it with a relative path. "Add External JARs" adds the jar with an absolute path which is not what you want.
If your paths are relative to your Eclipse installation, declare them using the “Add Variable…” button (in [Project] → Properties → Java Build Path → Libraries). There you should be offered a variable called ECLIPSE_HOME, which you can then Extend. This will produce a „kind=var“ entry in your .classpath(rather than a „kind=lib“).
<classpathentry kind="var" path="ECLIPSE_HOME/...
If your paths are relative to somewhere else you can declare your own variables (Configure variables). This way, when your workspace changes or someone makes a copy of it you just need to update these variables. This is often clearer than having true relative paths starting with one or two dots.
Please note that Eclipse relative paths should begin with a single dot.
Instead of
<classpathentry kind="lib" path="../3rd_party/example.jar"/>
You need to use
<classpathentry kind="lib" path="./../3rd_party/example.jar"/>
The first method might sometimes work, but the second method works always.
This is very confusing because you might have 5 entries in classpath that work with the ".." at the beginning and the others won't work with it.
Change all references to begin with the single dot first.
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>