NetBeans adding external library Vaadin Framework - netbeans

How can I add external library to Vaadin framework using NetBeans?
I can't find libraries folder there. Additionally I want use pi4j library.
I haven't seen it there like in normal Java Application Libraries folder.

Looks like you are using Maven. In that case you have to edit your pom.xml file (you can find it in the Project Files folder in NetBeans).
Google for the Maven coordinates for the library you want to include and add the corresponding dependency section in the dependencies section. For example, to add Log4j, you must add the following in your pom.xml:
...
<dependencies>
...
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
...
</dependencies>
...
Alternatively, you can right click the Dependencies folder in NetBeans, select Add Dependency..., and add the corresponding Maven coordinates or search for the dependency (keep in mind the Maven Index may be updated the first time you search for a dependency, process that might take some seconds/minutes).

Related

How do I update Itext7 to version 7.1.1

This seems like it should be simple but I cannot find anything on how to upgrade to newer versions of itext7. I am using an Eclipse maven project with itext7 version 7.0.4 and would like to update to 7.1.1. However, I can find nothing that tells me how to do that. Neither the Eclipse update menu or the Maven menu has an option to update itext7. Can someone point me to the documentation on how to do an update? TIA.
After answer:
I am not getting the libraries but instead getting conflicts:
I can't seem to post my pom.xml using code tags (I guess the formatter has a problem with XML code because of the <>) but I will include it if someone tells me how. I've uploaded the pom file to DropBox:
pom.xml
(Turning #mkl's and #amedee's comments into an answer)
In your project there is a file pom.xml which contains the Maven project definition. In there is a dependencies section with entries for the iText artifacts (among others). The version is therein. Well, it could also be in a separate dependencies management section or in a parent pom.xml referenced in your file.
As soon as you update the POM file, you can update the Eclipse project configuration in your Eclipse Maven menu. That will, if necessary, automatically download the jar artifacts. If your Eclipse Maven integration is properly configured, that is, and if your computer has proper internet connectivity.
Old versions will remain in your local repository but won't be in the class path anymore.
Also check out our getting started guide. Which contains an example POM snippet.
https://developers.itextpdf.com/itext7/download-and-install-information/Java
If you put your iText version number in POM properties, then you only have to update the value once when you want to upgrade. Like this:
<properties>
<itext.version>7.1.1</itext.version>
</properties>
and then
<dependencies>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>io</artifactId>
<version>${itext.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>layout</artifactId>
<version>${itext.version}</version>
</dependency>
...
</dependencies>

Importing a maven dependency using Struts 2 in Eclipse

I'm using eclipse with maven and I would like to include two struts tags :
<%# taglib prefix="s" uri="/struts-tags" %>
<%# taglib prefix="sj" uri="/struts-jquery-tags" %>
<%# taglib prefix="sb" uri="/struts-bootstrap-tags" %>
The problem is that the compiler says :
Can not find the tag library descriptor for "/struts-jquery-tags"
The library is correctly downloaded by maven through this declaration:
<dependencies>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.5.8</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.5.8</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.bootstrap</groupId>
<artifactId>struts2-bootstrap-plugin</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.jgeppert.struts2.jquery</groupId>
<artifactId>struts2-jquery-plugin</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
The maven dependencies are in the project's build path.
Why the struts-jquery-tags is not imported ?
PS : when I add the struts-jquery-tags's jar manually, I have no errors.
(There is another post dealing with the same problem but the answers are not relevant in my case).
Make sure that your project is maven enabled. Right click on your project select configure and then convert to maven project.
Then make sure you have maven dependencies set correctly.
In the eclipse right click on your project and select Build Path > Configure build path ... The select Libraries tabs. Make sure you have the Maven Dependencies in the list of your libraries. If the it is not there select Add Liberary and then Maven Managed Dependencies
I hope this will be a Eclipse issue.
I guess you've created a Dynamic Web Project and then converted it to a Maven project. When a struts project created in this way there are chances of getting errors which you mentioned.
As long as your project is running smoothly in the deployed server you need not to pay attention towards these.
I suggest to create struts2 project from maven repository. If project created in this way these kind of errors can be avoided.
The jar file is available here. You have the problem of downloading/packaging jar file. struts-jquery-tags is not imported because the plugin is not available on classpath.
If you need additional info you can check docs Building with Maven.

Eclipse plugin with Maven dependencies for third party libraries

I am converting Subclipse to build with Eclipse Tycho and Maven.
Subclipse depends on a few third party JAR files that are not Eclipse plugins so do not exist in any p2 repository. Currently, I just include these in a lib folder within the plugin.
Since these JAR files do exist in Maven, I was hoping that by converting the plugins to build with Maven I could use Maven dependencies. IOW, the plugin would have a pom.xml where I used Maven dependencies to grab and include the third party jar's that have to be included in the plugin. Basically, it would just automate having to refresh what I include in the lib folder of the plugin.
Is this possible? I tried doing what I said above by when I build, I saw no sign that Maven/Tycho was trying to fetch the dependencies. I imagine it is because when the packaging is eclipse-plugin it looks solely at the Eclipse configuration files for the dependency information.
Thanks
To add plain (without OSGi metadata) jar files into your folder at biuild time, you can specify an <execution> of the maven-dependency-plugin to fetch them. However it will require to update your MANIFEST.MF Bundle-Classpath directive whenever a version changes.
It's usually better to hunt for OSGi-able jars or to make an extra effort to package existing libs as OSGi bundles/p2 artifacts like Eclipse Orbit or JBoss Tools Locus do.
Did you try doing the following after adding the dependencies to the pom.xml file?
Project->Clean
Right click on project: Maven->Update dependencies
Right click on project: Maven->Update project configuration
Just adding the plugin to pom dependencies and including the entry <pomDependencies>consider</pomDependencies> in the configuration of target-platform-configuration makes it work.
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<!-- The configuration to make tycho consider the maven dependencies -->
<pomDependencies>consider</pomDependencies>
<!-- other configurations -->
</configuartion>
</plugin>
<!-- other plugins-->
</plugins>
<dependencies>
<!-- An example third-party bundle (plugin) present in maven repository-->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.gogo.shell</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
Reference link here.

eclipse maven external jars unable to compile

Maven compilation failes even after adding the external jars to eclipse. My Eclipse codes are okay with external jars, however when I compile Maven complains package blah blah not found, and I have almost 50 external packages.
I will use the mvn dependency to add the jars later.
However It should work, but not luck.
Any troubleshooting/suggestion please.
I think you can not get away with Maven Project without having <dependencies> tag in your pom.xml (Whether you run it from eclipse or from command-line) . That too for the project which is dependent on classes that are coming from 50 external jars.
If you don't want maven to look for these jars, you have to add below entry in pom.xml with system scope:
<dependencies>
<dependency>
<groupId>selenium-server-standalone</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>2.46.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/selenium-server-standalone-2.46.0.jar</systemPath>
</dependency>
</dependencies>
With this, groupID & artifactID are meaningless. You can write such 50 <dependency> tags for referring your 50 external jars.

Maven dependency and eclipse classpath

I tried to search for existing questions but cant find any - feels like my question is quite simple but probably because it's quite specific I cant find the answers on Stackoverflow / Google.
Anyways - I have few projects with Maven that are depend on each other. In certain cases I want the dependency to be on the JAR rather than a project dependency (ie. I want the dependency to be part of the "Libraries" in Eclipse rather than "Projects" in the Build Path).
Your help is greatly appreciated! Thanks
To get the referenced projects in the same workspace as jar files instead of the projects, we could use the VM parameter -Declipse.useProjectReferences=false or add it in the pom file.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<useProjectReferences>false</useProjectReferences>
</configuration>
</plugin>
See this URL for more info.
In your project properties in Eclipse, select Maven. There is a checkbox, 'Resolve dependencies from workspace projects'. If this is checked, then the Eclipse projects are used. Otherwise the jars are used as with other maven dependencies, assuming that you've got the dependencies in your pom.xml as normal.
EDIT: If your project is not a maven project, then you'll have to create the jar outside Eclipse and add it as a jar or external jar as normal. If the project is a maven project, then the above will work.
Say Client-Project depends on Services-Project. If Services-Project generates a JAR. In the Client-Project POM you would express a dependency on this JAR. It would be something like:
<dependency>
<groupId>group.id.of.services.project.goes.here</groupId>
<artifactId>artifact.id.of.services.project.goes.here</artifactId>
<version>version.number.of.services.jar</version>
</dependency>
If services project generates a JAR called com.mycompany.services-1.3.jar, the dependency would be:
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>services</artifactId>
<version>1.3</version>
</dependency>