How to resolve requirement: Import-Package: - java

The scope of this question applies after you have created an RCP app in eclipse following Vogella's tutorial linked below. This assumes your feature, product, and father project are created. In this state the feature is delegated the task of building, therefore all dependencies need to be resolved in the feature build.properties file.
This question addresses when the missing dependency needs to be installed, i.e. is downloaded manually because the missing dependency is not on the class path. The class path determines what plugins are available in the feature/included-plugins tab. The plugins listed in the feature/included tab can be added as plugins for dependencies to your plugin. This list gets appended to your feature.xml file which gets linked to your build.properties file! See Solution below.
Eclipse nomenclature interchanges the ideas of plugins=dependencies and treats them the same. We know this by the names of the tabs.
The intent of this question is aimed at using existing Eclipse capability to develop an RCP application that uses objects from a third party plugin to create a custom workflow.
This error is thrown because my RCP app third party plugin requires this dependency which was not included in Eclipse ICE nor the plugin itself.
The first thing I tried was to install the plugin directly from the Eclipse Marketplace.
The string org.apache.commons.beanutils returned nothing so I went to apache and downloaded the plugin manually.
I then researched how to install a plugin in Eclipse manually.
I've learned not to simply drop the plugin into the Eclipse/dropins folder, which does nothing.
I've learned that this advice is lacking probably due to age of post.
I've learned when Maven is configured correctly, all the dependencies can automatically be resolved.
https://www.eclipse.org/forums/index.php/t/813199/
This says plugin dependencies are resolved by looking at four files.
"The plug-in definition, the product file, the run configurations and the target definition."
The plug-in definition I'm not sure what that is other than the plugin.xml file. The product file has been configured to launch the third party plugin. I've learned the run-configuration has a list of plugins and the third party plugin is not listed there.
I've learned that the target definition should be created in the parent project of your product project.
Create a target definition by highlighting your father project->Right click-> new-> Other-> Target Definition. During creation select "Use workspace configuration." The path to your downloaded plugin was added to this Location.
After the Target is created, Navigate to the content tab and select Manage Using: Features
This reduces the number of possible dependencies to only the ones needed to run.
You should now see the dependency checked in the list.
Creating the target resolved the other twenty or so dependency errors but the one under the title still throws an error.
I've learned that the product file is the file that calls the third party plugin in runtime.
The RCP app launches, but I cannot import the third party plugin in the bound classes created using this tutorial, to be used to obtain objects programmatically.
http://www.vogella.com/tutorials/EclipseRCP/article.html
I have a shell of a program running and just need to implement the classes for each window with the objects I can get from a third party plugin import.
Thanks,
(Solution)
Thanks Brian for resetting my thinking which led me to learn about Eclipse a little more to figure this out.
The main problem is an external .jar is identified as the missing Import-Package. Mine was org.apache.commons.beanutils. You must go to the parent website and download the library. In this case apache's website. There is probably a better way to do this by repo. I'm hoping I can export the product with all the required dependencies :p
I may be able to skip a step or two here, but these were my working steps.
Get .jar into Eclipse parent project. Right click the parent and select New->Folder->Name it Lib->Finish. Right click Lib->Import->File System->Navigate to .jar. Highlight the included .jars->Right Click->Build Path->Add to the Build Path.
Add the missing .jar to your Ant class path. Ant is used to build PDE apps using OSGi. See the Eclipse Help for an explanation. This will allow your missing jar to become visable in the feature project included-plugins tab.
Window->Preferences->Ant->Runtime->ClassPath Tab->Add jar->Navigate to missing jar
Create a target definition as described above in your parent project and add your missing .jar to the target and set your target active.
If target exists, In Locations widget window->Click Add->Directory->Navigate to missing .jar.->Next-> Verify plugins are recognized in window->Finish. Click Set as Target Platform in upper right corner.
Open feature.xml in your feature child project. ->Click Add->Navigate to your added plugin->Click Ok
Save All - Launch product
Now onto the next dependency!

Sounds like you're confusing an Eclipse plugin with a jar dependency for your project. it sounds like your project needs a jar (the beanutils jar from Apache) . Depending on if your project uses Maven or ant (or something else) the way to add it to your project varies. Try googling something like "adding a jar in eclipse for a X build" where X is the tool used for your build (ant, maven, etc). No matter what you use, the end goal will be for that jar to show up the java Build path->Libraries for your project in Eclipse.

it seems to me that u need a better understanding of how dependencies are managed in OSGI/eclipse, therefore i concur with BrianPipa.
beware: that subject is quite large and not easy to understand and is way too large to be explained here. but be not afraid, google is ur friend:
a few pointers on research topics:
the relation ship of bundle/plugin and jars
how is code contained in a plugin exported (aka make visible) to other plugins so they can use it AND what needs to be done so that the using plugin (ie. declare that usage-dependency)?
how are feature related to plugins?
how are products related to plugins and features?
what is a target platform ?
and how do i define it and what does it need to include ?
how do i set it ?

Related

Project is missing required library - but correct JAR exists?

One of my eclipse projects gives me the Project X is missing required library: 'somelib.jar' error, but when I go to Configure Build Path > Libraries the library is present, and no error is indicated there.
I tried the usual things:
Clean build (all projects in the workspace)
Exited eclipse multiple times
My coworkers, using the same git checkout with the same status as mine, and also using eclipse Neon2, have no build errors.
Just to be sure, I navigated into the corresponding directory and removed a different jar file, and when I look at my build path configuration that jar shows up with a red "x" indicating that the library is missing.
I checked that somelib.jar sits in the expected place and is a valid JAR file.
How do I fix this?
These steps did resolve the problem:
closing / re-opening the corresponding project
another "full" clean of all projects in the workspace
In other words: it seems that a simple F5 "refresh" and a even a "clean project" isn't sufficient sometimes. So closing the project is the key element here!
Some times eclipse becomes naughty following steps should be taken to nicely add the jar library in project
First remove the library from libs folder
Also remove the refrence from java build path in external library tab
Clean the project let it actually realize the library is missing :D
Again copy the jar file in libs folder
Add the refrence of library in java build path library tab
set the priority of this library to top (important) because its
possible the order of library export is not ok in your project
Clean the project and build
hope so it will solve your problem
If you have multiple projects opened in such way that one depends on another, and the problematic project depends on others, refreshing all dependent projects will fix the 'missing library' issue for the main project.

Convert Java Project into IntelliJ IDEA plugin?

I am developing a plugin for IntelliJ as part of a larger research team. The logic for the plugin was developed and tested as a Java project in IntelliJ IDEA. Now the time has come to develop the front end, and the module is not configured as a plugin. How should I go about converting the Java project to a plugin project?
It is not reasonable to start the project over as a plugin project, because it has complex dependencies on several other modules.
This is a similar question to how to import existing plugins, but is different because the code is not a plugin yet.
These are the steps I have followed so far:
Create a new action class (that extends AnAction) to be the main class for the plugin.
Create a run configuration for the plugin. I get this error: Run Configuration Error: No plugin module specified for configuration
Follow the instructions given by OpherV in the question I linked to above to change type="JAVA_MODULE" to type="PLUGIN_MODULE" in the .iml file.
The third step did not resolve the "Run Configuration Error: No plugin module specified for configuration issue." What additional steps are needed?
I am using IntelliJIDEA (Community Edition) 14.1.4 Build #IC-141.1532 on OSX 10.11.1.
I was able to successfully convert the project into a plugin by following these additional steps:
Create a META-INF directory in the root of the project. Inside of this directory create the plugin.xml file. In plugin.xml, register your action. See the IntelliJ code samples for examples of what this file should look like.
Right-click on your project root in the project view (Cmd-1 if it’s not open already) and choose “Open Module Settings” (Cmd-down). This will open Project Structure > Modules > Dependencies.
5.1. Alternately, you can get here by opening the Project Structure with Cmd-; and then choosing Modules and picking your project from the list and going to the Dependencies tab.
Make sure the module SDK is the IntelliJ Community Edition instead of the normal Java 1.8 (or whichever version you have). (I noticed that this changed a line in the .iml file, but you should change the SDK here so you can create it as described here.)
At the bottom of the dependencies window, there is a plus. Click it, and follow the instructions given by samkass in the answer to this question, which I will reiterate here with more context-specificity for ease of following them:
7.1. Once you have clicked on the plus button, select “Jars or directories…”
7.2. Navigate to the META-INF folder, select it, and click OK
7.3. In the dialog that comes up, select “classes” and NOT “jar directory”
7.4. Make sure you’re using that Module in your run target
Once I followed all of these steps, the "Run Configuration Error: No plugin module specified for configuration issue" went away and the Run Configuration I had created worked. I ran it and my action was available in the Refactoring menu as I had registered it in plugin.xml.

How can i open an Akka project using eclipse?

i am trying to create a simple hello-akka project using the typesafe activator. I have everything working and the project even runs in the typesafe tab. I clicked on create eclipse project, and some files are added to my directory but i cannot figure out how to open them and run the file in eclipse!
These are the files i currently have in the directory:
.sbtserver
project
src
target
gitignore
(GITIGNORE FILE?)
activator.bat and activator.jar
build.sbt
In another workspace i tried creating my own scala project, by adding akka-actor.jar to the libary but i get the following error :
Description Resource Path Location Type
missing or invalid dependency detected while loading class file 'ActorSystem.class'. Could not access term typesafe in package com, because it (or its dependencies) are missing. Check your build definition for missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.) A full rebuild may help if 'ActorSystem.class' was compiled against an incompatible version of com. tst Unknown Scala Problem
Any help or suggestions would be greatly appreciated!
There are quite a few dependencies you'll need to find and add if you're determined to make this work -- a scala-library, for example. It's better to find a way to integrate your build with your IDE if you can -- this will allow the IDE to find dependencies the same way the build does -- and in this case, the build system is SBT.
The easiest path forward may be to download ScalaIDE, which is a Scala specific package for Eclipse. This should come ready to go with support for SBT projects. Most Actor/Scala devs I know use IntelliJ or ScalaIDE.
Another option would be to use the SBT plugin for Eclipse, but in my experience it tends to be unreliable, changing with far less frequency than the IDE itself. If you install it and it doesn't look like it's working, you're probably right.
Finally, you can ditch SBT for Gradle or Maven and then use the Gradle or Maven plugins for Eclipse. If you have either of those in your shop already this is likely something you will need to do down the road, anyway. SBT is a good build system but nowhere near as feature rich as Gradle or ubiquitous as Maven.

How to add source files of library jars?

I am using Eclipse IDE and its derivative like Spring IDE for Java development.
In a web application project, I add external jars like Spring MVC jars, Apache commons jars etc to the Web App library folder, hence they are automatically added to the build path. There are many jars in the Web App library folder.
I want to create folder in the project and add all the source files (zip/jar) of the libraries included in Web App library folder, so that I can navigate through the source of libraries from the Java editor window. Whenever I add a source zip/jar file to this folder, Eclipse should detect it and use it whenever I want to navigate to the source of a library.
Is the above possible in eclipse?
Note: I know how to add source files
for each individual jar by navigating
to the build path window and
specifying the source location. But
this is very crude way, and I need to
do for every library individually.
Also the drawback is that source path
is absolute, which means if I import
the project into another computer then
I need to create the source path or
even worse I might have to add the
source files individually again.
One way to automagically get the sources for the jars would be some kind of dependency management system. Most people would scream Maven (2/3) by now, but others exist and work well. Maven does have nice Eclipse integration, so that should be a plus.
The downside is that setting up a Maven project just for it's dependency management can seem overkill. Another point is that all the jars you depend on should be "Mavenized" as well.
As far as I know Eclipse wont automatically detect/scan source archive files and link them up to libraries in your workspace in the way you described it.
I agree with #Gressie on using Maven and the Eclipse Maven plugins -- as in that case it's just a matter of ticking a few boxes and Maven will do that for you.
If however your project is not Maven-ized, you can still do this in Eclipse but it's more tedious:
for each one of the jars in your project (which appear under the dependecies section) right click on it and select properties
in the dialog that pops up you have (at least) 2 locations you can configure: java source attachment -- simply browse to your jar with the sources -- and also javadoc location (point it to the jar with javadoc if you want the javadoc to appear as a tooltip when you hover the mouse over one of the classes/methods/etc in that library).

adding user defined libraries to SVN

I am developing a project for which I have used a number of external libraries (in jar format). I have added all of the external jars I have downloaded and added to the build path to our version control (subversion) as well.
However it has recently come to my attention that a number of the libraries are not in the SVN tree. I have looked into it a bit, and these are the libraries that I have created as user defined libraries and added to the build path in that way, following the instructions on the respective web pages. When I right click on them in Eclipse, I don't see the options to add them to the version control. So I decided to export them to the lib folder I have on the SVN tree. I am not sure if it's the right way of solving this problem, would appreciate som help on the matter.
I am not sure if it's of any help but the packages in question are: Commons Math, JFreeChart and JCommons.
Have you considered using something like Maven or Ivy for your external dependencies?

Categories