In Eclipse, if a project uses a particular JAR file, I can mark it to provide/export it.
So if another project has a reference to the former, then the particular JAR will be available too.
How can I do that in Netbeans?
In Netbeans you always have to add JAR in the project properties, unless you use some deployment tools.
Right click in your project
Project Properties -> Libraries
Add JAR
Related
I have created a maven project in eclipse using the maven2eclipse plugin.
I then convert the project to a web module project by going to project facets in the project properties.
The problem is that when I attempt to create a class under the directory src/main/resources, none of my classes compile. I can put any sort of junk in the classes and the compiler doesn't give me any warnings. Also, the package I create doesn't create a "brown package" but a folder instead.
Does anyone know what I have configured wrong?
src/main/resources is intended to hold... resources: properties files, images, etc. that are copied to the classes directory. Java source files must be put in src/main/java.
You can try this : right click on your project > maven > update project configuration. It will configure you .classpath and .settings against your pom.xml configuration.
The problem was that when you switch to this web module in project facets, the "exclude *.java" files is entered under java build path > source by default. This must be removed.
Have upgraded to eclipse.indigo using a new installation. Added m2e. Maven shows up under Windows>Preferences. File>New>Other>Maven gets the following options: Checkout ..., Maven Module, Maven Project. The Maven POM file option is missing. I'm trying to add Maven support to an existing Java project. Have read the manuals, searches, helps, etc. No explanation as to why the Add POM option is missing. Any idea how to get this option to appear?
In order to create a POM on your project, and also change the project structure to Maven default, right-click on your project > Configure > Convert to Maven Project.
Don't forget to choose the correct Packaging type (in your case I guess it will be POM).
I don't have this option either, seems to have disappeared with the latest version. This bug report seems to point in this direction as well:
https://issues.sonatype.org/browse/MNGECLIPSE-2709
The standard way should be to create a new Maven project through the wizard, which will then also contain a POM file. You could use that to create a dummy project and then copy over the POM file.
In most cases, I also just copy an existing POM file to the project and start with that.
Quick workaround: Adding a POM by hand. (Also I'm not sure that I've ever seen an "Add POM" option.)
Simply add a file to your project (New > General > File), and name it pom.xml. On double-click on this file, the POM Editor will open.
I have a Java project with sub-projects that is currently built using NetBeans's IDE-generated Ant scripts. I am converting the entire project to a Maven build.
My Maven build works fine from the command line and loads perfectly in Eclipse. However, the only way I can get the project to load as a Maven project in NetBeans is to delete the Ant scripts, i.e. build.xml and the directory nbproject for each sub-project. It seems that as long as I have the old IDE-generated build files, NetBeans recognizes the project as a NetBeans Java project only, not as a Maven Java project, even though there is also a pom.xml file present.
Short of deleting the IDE-generated build files, is there any way to tell NetBeans to load the project as a Maven project?
I have been told that we want to keep the Ant build for a while during the transition to Maven.
Using NetBeans 6.9.1, Maven 2.2.
Any help would be appreciated.
Thanks
Well, the nb ant project metadata has precedence over occurence of pom.xml file (that's how maven projects are recognized and loaded). The whole precedence order hardwired in the IDE, you could only influence it be uninstalling the j2se ant project type for example.
So, yes. You need to get rid of the ant project metadata before you can open the project as maven project. Depending on how and when you delete the metadata, you might need to restart the IDE as well to get the new stuff loaded.
Have you seen http://wiki.netbeans.org/MavenBestPractices? It indicates that you must install the NetBeans maven plugin first. Perhaps that's why your Maven projects aren't recognized.
I must note that I'm not a NetBeans user anymore!
Here is what I ended up doing:
I wrote an Ant script (ironic, huh?) that, for every subproject of my project, renames the file nbproject/project.xml if it exists to nbproject/nb_project_disabled.xml. If nbproject/nb_project_disabled.xml exists instead, the script renames it back to nbproject/project.xml. In this way, the script toggles the opening of the project as a NetBeans Ant build or as a Maven build.
It would be nice if NetBeans, you know, had a setting to open both kinds of projects. Currently (6.9.1), there is just the "Open Project" command. In Eclipse, there is the command "Import Existing Maven Projects" vs. "Import Existing Project Into Workspace" (i.e. native Eclipse format).
I try to build a Eclipse plugin that has to use a self written jar which is dependent on other jars, but I don't get the point where to start with handling jars as seperate PlugIns. Anywhere I have to use just the .jar files or am I wrong?
I think I found a proper solution; the trick is that you have to implement all the files via Eclipse. I just copy here the solution which was posted to news.eclipse.platform:
Include the jars in a plugin:
Use Import > File System to import the jar files into your plugin project, say in the <project>/lib directory.
Use Add... button to add the jars to the classpath section of the plugin.xml > Runtime tab.
Use New... button to add "." library back (with no quotes, of course).
Make sure your binary build exports the new jar files on the plugin.xml > Build tab.
Save
On the project, use context menu > PDE Tools > Update Classpath to correctly add the jars to the eclipse project classpath.
What is a self-written jar?
Normally you turn 3rd party jars into bundles using an OSGi MANIFEST.MF (See New>Plug-in Development>Plug-in from Existing JAR archive) or you include them in your plugin.jar and add extra Bundle-ClassPath entries as mentioned by TomaC.
If you mean at runtime your plugin will create a new jar and needs to load it, that's different, though.
Project Properties -> Java Build Path -> Add External jars. Is this what you are looking for?
In our code base we have a dependency on the ant version used in eclipse.
In the the ant.jar has been set up as a library which the project uses
This is a pain when moving versions of eclipse as the Ant plugin folder name changes (although I see it is now just called Ant1.7)
Is there a way to access eclipses reference to ANT Home which appears in the workspace preferences so that I don't have to explicitly set a variable that has the hard coded path to the ant plugins folder
Your project should not have a dependency on eclipse's version of Ant in the first place, you should keep your own version so as to decouple your project from eclipse. What if a developer or yourself decides to use intelliJ?
Although i don't know what the nature of your project is, i would have thought all dependencies should be added to your projects lib directory or something similar.
One possible suggestion would be to :
transform your project into a plugin project (properties on your project / PDE tools / convert Project to Plug-in Projects...) and
add to its dependencies the 'ant' required plugin.
That would be easier to manage when you change the version of eclipse.
Have you considered installing Ant separately, creating an environment variable, and then referencing the location via the ANT_HOME environment variable within your Ant build.xml?
From within your eclipse, on the package explorer view, right click on the specific project and build path.
Move into the Libraries tab and select the "Add Variable..." button. From here you'll see that is where the JDK system libraries path, maven(if you're using it, tomcat, eetc...) If ANT_HOME doesn't appear, you can add it by clicking the Configure Variables... button. From this moment, the ANT_HOME path will be considered in the build path of the project.
Hope it helps.
Carlos
Your ant home is available in the property ${ant.home}
E.g:
<echo> ${ant.home} </echo>
Gives the following on my machine:
[echo] D:\java\eclipse_3.4_jee\plugins\org.apache.ant_1.7.0.v200803061910