How to change Liferay Portlet Plugin API library in Eclipse? - eclipse

I have switched my web-application to run on another installtion of Liferay. Consequently, I was able to changle classpath libraries in my project to new server location. This includes JRE System Library and Liferay v6.0 CE. I.e, both these libraries can be added for new server location from Java Build Path dialog.
But the library "Liferay Portlet Plugin API" still refers old Liferay installation path and I see no way to change it.
How is it possible?
UPDATE 1
Here: http://www.liferay.com/community/wiki/-/wiki/Main/Liferay+IDE+Getting+Started+Tutorial
On the very most low picture you can see all three libraries listed in Package Explorer. Two of them I was able to change and the question is about third one.

You can manually change file .metadata\.plugins\org.eclipse.jdt.core\variablesAndContainers.dat.
So open your filesystem browswer (My computer) navigate to your liferay IDE workspace location and go to .metadata\.plugins\org.eclipse.jdt.core. Open file variablesAndContainers.dat and find and edit your jars locations.
After that restart Liferay IDE or simply close and open your project.
UPDATE:
1) Take note of jars that are needed
2) Go to configure build path dialogue than go to libraries and select "Liferay Portlet Plugin API" then click Remove
3) Create folder "lib" directly in your project (not WEB-INF/lib)
4) Add jars to lib folder (from 1.)
5) Select jars and add them to build path (right click - Build path - add to build path)
Or you can crete you User libarary with those jars and than add it to build path

Additionally to chosing correct libraries in classpath dialog, one should also change "target runtime" appropriatedly by right click project and going to properties > Targeted Runtimes.
P.S. And plus one should close project and then open it again.

in my case, following instructions in this question about clearing eclipse cache (-clear option) helped, as changing liferay plugins SDK path wouldn't change the libraries' locations when adding this library to project build path...

Related

Eclipse Kura OSGi Dependency Management

Preface: I'm new to Eclipse, OSGi, and Kura
I'm trying to develop a Kura plug-in that depends on org.apache.httpcomponents.httpclient. I found an OSGi bundle for the package here.
Currently, the only way I'm able to use the plug-in (with the OSX Kura emulator) is to download httpclient-osgi-4.5.jar and add it to ~/Documents/workspace/target-definition/common/repository/plugins/. Otherwise I get a class not found error.
When I add the plugin to MANIFEST.MF either as with REQUIRE-PLUGIN or IMPORT-PACKAGE, Eclipse cannot find the package.
What's the correct way to require, fetch, and add to the classpath a remote dependency using Eclipse Kura/OSGi? Eclipse currently only looks in my local workspace for dependancies, is there an accepted way to fetch remote plugins?
Thanks for the help!
The bundles located in target-definition/common/repository/plugins are part of an M2 repository created by the Kura build. It is not enough to simply copy your required bundle to that directory. The solution I typically use to accomplish what you want is:
Double click the kura-equinox_3.8.1.target file located in target-definition. This should open in the Eclipse IDE.
Under "Locations", click "Add...". Then select "Directory" and "Next". Select the folder containing your required additional bundles and click "Finish".
Save the kura-equinox_3.8.1.target file and click "Set as Target Platform". Your new bundle should now be available in Eclipse.
Thanks,
--Dave
What for me works is;
Simply copied the bundle in ${workspace_loc}/target-definition/common/repository/plugins
Clicked on reload
Clicked on Set as Target Platform
After these steps, Eclipse is aware of my bundle and could able to use it anywhere.

How do I integrate the Java EE docs / API into Eclipse?

I want to set up my Eclipse installation so that when I use the content assist and hover over / inspect a method therein, it shows me the Java EE documentation. How do I integrate it?
You'll need to locate your documentation and your server's servlet JAR, and then add the JAR to your installed JRE and attach the documentation. This answer presumes you have already installed your server and integrated it into Eclipse.
Documentation
You can link to documentation in a few ways:
Online (e.g. http://docs.oracle.com/javaee/6/api/)
To a local JAR or ZIP file
To a local folder containing the extracted docs
Whichever way you decide, be sure you have the location handy.
Servlet JAR
You'll need to find the servlet JAR for your server setup. The JAR and its location depend on which server you use. Navigate to your server's installation directory and find the file as follows:
Tomcat: lib/servlet-api.jar
Glassfish: modules/javax.servlet-api.jar
This list is by no means exhaustive. Regardless, be sure you have the JAR's location handy also.
Add the Servlet JAR to the JRE Installation in Eclipse
Navigate to your JRE installation as follows:
In Eclipse, open the Window menu, then select Preferences.
In the search bar, type jre, and then click Installed JREs.
You can also navigate by expanding the Java tree and selecting Installed JREs.
Select the one named java, or another term like jre7.
Its type must be Standard VM.
Then, edit the installation:
Click the Edit button.
In the JRE system libraries section, click the Add External JARs... button.
Navigate to your servlet JAR and click the Open button. It appears at the bottom of the list.
Attach the Documentation
First, select your newly-added servlet JAR and click the Javadoc Location... button. The way you attach the documentation depends on its source.
Online or extracted documentation
Ensure the Javadoc URL radio button is marked (it is by default).
In the Javadoc location path field, enter or Browse for your documentation location, specifically the path containing package-list and index.html.
JAR or ZIP documentation
Ensure the Javadoc in archive radio button is marked.
In the Archive path field, enter or Browse for your full documentation path (e.g. /home/docs/jdk-6-doc.zip).
In the Path within archive field, enter or Browse for the path containing package-list and index.html (e.g. docs/api).
Finishing the Attachment
Click the Validate button to ensure everything is set correctly.
Click the OK button, then the Finish button, and finally the OK button.
Your documentation is now linked to the servlet you specified and ready for use in Eclipse. =)
References
Off-Line Java API Documentation in Eclipse?
Integrating Javadoc for Java EE 6 API into Eclipse
where is the servlet-api.jar in glassfish installation?

Eclipse - Adding a Jar File to a existing Project

I am running Eclipse 3.7. I am currently working on a Plug-In Project for a Application called Team Center. I was recently made aware of a jar file of SWT Widgets named Opal. So I am trying to figure out how to add the Jar File to my existing project. I have tried many different ways to do this. Nothing has worked so far.
Here are some of the things I have tried.
Made a lib directory in my current project copied the jar file
Build Path Configure -> Libraries -> Added the Jar
Runtime tab -> Add -> selected the lib/jar file -> update build path
Saved
My project still compiles, but at runtime it fails and I get can't load proxied handler errors
I have tried to create a plugin project just for the Jar File, then add the opal plugin to required Plug-ins. If the Opal project is closed, that reflects with the Opal plugin in my project.
Here is the way my current project works. It is a plug-in project and when I finish or change code.
Build Project
Export
Deployable plug-ins and fragments
Select my project plug-in
Finish
Then I copy the project.jar to the TeamCenter Application plug-ins directory
I am assuming that somehow I have to include the opal.jar in the project.jar. But right now I am at a total lost on how to do it.
In Eclipse Plugin Project click on your MANIFEST.MF file and go to the runtime tab. There should be a section "Classpath". Try to add your lib there.
UPDATE
I've tried it and it has worked for me. I've executed following steps:
create new Plug-In project
create new lib folder in it
copy opal lib to the folder
open the MANIFEST.MF, go to the Runtime tab and add the lib to the Classpath section
check whether the lib folder is recognized of the build process (Build tab and lib folder should be checked)
Create new Run Configuration (Run -> Run Configuration... -> double click on OSGi Framework)
on Bundles tab check the new made project (Workspace section) and uncheck Target Platform for now
mark the new project and click on the button Add Required Bundles on the right side
now some needed bundles to run your project should be checked in the Target Platform section
click Apply, then Run and your OSGi env will be started
check build.properties in your plugin. check lib folder should be included there.
open plugin.xml or MANIFEST.MF in editor, you see build Tab. In the binary build, make sure your lib folder is checked.

Configure the build path in eclipse for Spring MVC Step-By-Step Tutorial

I begun this Spring MVC Step-By-Step Tutorial part 1 at 1.8 it says
"If you are using an IDE, you will want to configure your project's build path by adding the jars from the 'lib' directory. You will also want to add servlet-api.jar from your servlet container's 'lib' directory ('${appserver.lib}'). Adding these to your build path should successfully resolve all the import statements in the 'HelloController.java' file."
I add jars in the 'lib' folder but the issues does not solves. I could not figure out how to configure the build path. Can any one help. Thanks
Right-click on your project root and select Build Path -> Configure Build Path.... Select the Libraries -tab and click Add JARs.... Navigate to your projects' lib-folder and select the .jar -files, then click Ok.
Edit:
From the comment below:
can I define the library once and for every project I just mention the
path
If you have multiple projects that use the same jar-archive or archives, you can define a User library for your Eclipse-installation: Select Window -> Preferences, then Java -> Build Path -> User Libraries. Click New, give a name to your user library and click Ok. Select the User library you just added, and click Add JARs..., navigate to the jar you want to add to the library and click Ok. Note that single User library can contain multiple jars (such as all needed Spring-jars, like core, webmvc, tx...), so you can keep repeating the Add JARs... -step.
When you want to use the defined user library in your project, go to the Libraries -tab in your projects' Build Path, and click Add Library, then select User Library and click Next. Now you can pick the library from your user libraries you've defined.

Eclipse: How do I add the javax.servlet package to a project? [duplicate]

This question already has answers here:
How do I import the javax.servlet / jakarta.servlet API in my Eclipse project?
(16 answers)
Closed 7 years ago.
I'm using Eclipse 3.6 Helios (for Java Developers) and want to add the javax.servlet package to one of my projects.
What do I need to configure/download?
To expound on darioo's answer with a concrete example. Tomcat 7 installed using homebrew on OS X, using Eclipse:
Right click your project folder, select Properties at the bottom of the context menu.
Select "Java Build Path"
Click Libraries" tab
Click "Add Library..." button on right (about halfway down)
Select "Server Runtime" click "Next"
Select your Tomcat version from the list
Click Finish
What? No Tomcat version is listed even though you have it installed via homebrew??
Switch to the Java EE perspective (top right)
In the "Window" menu select "Show View" -> "Servers"
In the Servers tab (typically at bottom) right click and select "New > Server"
Add the path to the homebrew tomcat installation in the dialog/wizard (something like: /usr/local/Cellar/tomcat/7.0.14/libexec)
Right click on your project -> properties -> build path. Add to your build path jar file(s) that have the javax.servlet implemenation. Ite depends on your servlet container or application server what file(s) you need to include, so search for that information.
When you define a server in server view, then it will create you a server runtime library with server libs (including servlet api), that can be assigned to your project. However, then everybody that uses your project, need to create the same type of runtime in his/her eclipse workspace even for compiling.
If you directly download the servlet api jar, than it could lead to problems, since it will be included into the artifacts of your projects, but will be also present in servlet container.
In Maven it is much nicer, since you can define the servlet api interfaces as a "provided" dependency, that means it is present in the "to be production" environment.
Go to
JBoss\jboss-eap-6.1\modules\system\layers\base\javax\servlet\api\main
include JAR
jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar
For me it worked
For me doesnt put jars to lib directory and set to Build path enought.
The right thing was add it to Deployment Assembly.
Original asnwer
Download the file from http://www.java2s.com/Code/Jar/STUVWXYZ/Downloadjavaxservletjar.htm
Make a folder ("lib") inside the project folder and move that jar file to there.
In Eclipse, right click on project > BuildPath > Configure BuildPath > Libraries > Add External Jar
Thats all