How to include JAR to Liferay portlet in Eclipse - eclipse

How to import jsoup.jar to Liferay portlet, through Eclipse IDE?

just copy your jar file into docroot/WEB-INF/lib folder of your portlet. if you create your portlet correctly using eclipse and Liferay IDE(plugin), eclipse automatically recognize your lib folder and jar files under it into classpath

liferay has ivy settings. you could just locate the ivy.xml file in your liferay-plugin-sdk-6.2 folder (this normally reflects in eclipse as a project folder with your version). add this line <dependency org="org.jsoup" name="jsoup" rev="1.8.1"/>
and then build "all". You'll see it download the dependency. When done, navigate to liferay-plugins-sdk-6.2/.ivy folder, look up the downloaded jar and copy it to your project's lib folder i.e /lib. Go to project properties, then Java Build Path. In the libraries tab, click Add JARs and navigate to /lib and add it.

Related

Automaticly add 3rd pary jars to Tomcat's lib folder

I'm using Eclipse Neon 4.6 and Tomcat 8. I have my deployment assembly set with external jars via user libs and dependent projects. When I clean and build the project only the dependent project's jar files are added to Tomcat's WEB-INF/lib folder, not the 3rd party external jars even though they are specified in user libs and the lib is in the deployment descriptor. Any ideas as to why Tomcat isn't automatically coping the user lib jar files? One interesting note is that if I put the jar files in the project's WEB-INF/lib folder they are not picked up at run time either. I have also tried adding WEB-INF/lib to the deployment descriptor without any luck.
So I figured this. Turns out I correctly had libraries as dependencies in the project but did not mark them for export in Project | properties | Java build path | Order and Export. I had to check the libs for export. Now they are included in the WEB-INF/lib folder when I create the project WAR file.

How to convert properly Eclipse project to Maven project?

I have created in Eclipse Dynamic Web Project. Then I have selected option 'Convert to Maven Project' from 'Configure' from right-click menu. And now I can see red errors on Java Resources folder in my project. But none subfolder is with red error. In which way can I resolve that problem? I am using Eclipse Juno and m2e plugin.
I have recognized that m2n plugin haven't created src/main/java, src/main/resources and src/main/webapp directories in Java Resources. But the error is still the same.
The process in manually. You need to create a pom.xml and change your folder structure to follow Mavens conventions. I would recommend to create a web project via maven archetypes and move your project step-by-step into the new structure.

trying to use tess4j for the first time with eclipse(any step by step for trully beginner)

I need a step to step on how to plug tess4j to Eclipse.
I found this online:
creating a lib directory and copied the tess4j.jar and its required jar in;
added the jars to build path
copied the tessdata directory and tessdll.dll file into the project root directory.
Now it just works.
I only know basic Java so I have no idea what creating a lib directory and copy directory file means at all.
Can someone help me to plug this library and make it work for eclipse because I am working in a project that needs ocr.
creating a lib directory and copied the tess4j.jar and its required jar in;
A JAR (Java ARchive) file is a collection of compiled Java classes. This is the usual way to distribute Java libraries. You should create a new folder in your project (right click your project, "New", "Folder") and copy/move the JAR you downloaded to this newly created directory. If tess4j has dependencies, i.e. needs other JARs to work, you have to put them in this directory.
added the jars to build path
You need to tell Eclipse to add the JARs to the build path, i.e. Eclipse needs to know where to get the tess4j classes from. Locate the lib folder and select all JAR files. Right click them and select "Build Path", "Add to Build Path".
copied the tessdata directory and tessdll.dll file into the project root directory.
Should be clear ;-)

Can I add predefined jars to WEB-INF/lib in Eclipse project?

When I am designing normal Java project in Eclipse, I can add predefined libraries to it's Build Path. Can I do the same way when putting jars into WEB-INF/lib folder of Web project? I.e. can I ask Eclipse to put some predefined library jars there?
Just copy / import a Jar there; it will be added to the build path automatically. You will find it in the package explorer within the Web App Libraries (or in the build path in the project properties). The project has to have the Dynamic Web App nature.
This is what I did. I copied the jar files into my WEB-INF/lib folder. Then, I added these jars into my build path using: Properties -> Java Build Path -> Add Jars -> Select the jars from the WEB-INF/lib folder.

Imported maven project but can't see jsp in WEB-INF in eclipse

I checked out a maven project, the directory looks like this :
.settings
[bin]
[src] inside this folder there is [java],[resources] and [webapp] folders.
inside [webapp] there is index.jsp and [WEB-INF].
inside [WEB-INF] there is web.xml and [jsp] folder.
[target]
.classpath
.project
pom.xml
I did :
File --> Import --> Existing Maven projects
The project now appear in Project Explorer of Eclipse with this contents :
src/main/java
src/main/resources
src/test/java
JRE System Library[JavaSE-1.6]
Maven Dependencies
bin
src
target
pom.xm
My question, where are :
WEB-INF and jsps ?
Thanks, your help is appreciated.
John
Down below the source files that you described, you should see a "src" folder (with nothing after it). Drill into this folder and you should find your missing files.
Did you run mvn eclipse:eclipse?
First off, you will need to make sure you have the Eclipse Maven Plugin installed. You can get it here. Once thats there, you will need to run mvn eclipse:eclipse on the project base folder on command line. That will create .project, .settings and .classpath files, making it a valid Eclipse project. Now start Eclipse, select File -> Import -> Existing Projects in Workspace and navigate to the project folder. You should be able to see the project with Maven folder layout now.
You should look at m2eclipse plugin to work on maven projects in eclipse. Assuming you have installed this and m2eclipse extras (for WTP support), import the project in eclipse as a maven project. The jsps should be show up in Web Resources (src/main/webapp).
Note that this plugin does not need you to run mvn eclipse:eclipse either. If you have done this and want to undo it, you can run mvn eclipse:clean.