Add external jars to Eclipse plugin classpath - jar

In the manifest file for an eclipse plugin its possible to add jar files and
folders to the classpath (on the Runtime tab).
In the root of my plugin I have a folder lib containing a-1.0.1.jar, b-1.0.0-SNAPSHOT.jar. But only when I select each jar separately:
Bundle-ClassPath: .,
lib/a-1.0.1.jar,
lib/b-1.0.0-SNAPSHOT.jar
...can they be used inside my project. Why is it not possible to add them to the classpath by adding the common root folder only:
Bundle-ClassPath: .,
lib/
?

No, you can't. Eclipse is based on OSGi, which is the platform providing MANIFEST.MF support to build plugins.
When you set values under Bundle-ClassPath, OSGi search into each one to find class files. So you can put folders containing Java packages and class files. When you put a jar file, it is uncompressed in memory and viewed by OSGi as a regular folder, still searching for class files.
Unfortunately, there is no way to load all jar from a folder. No wildcard mechanism or something like that is allowed here.

Related

What's diff between paches and plugins

I change the code in repo carbon-apimgt, and i run command "mvn clean install -Dmaven.test.skip=true" , I get a jar from target, what's next to apply this change?
Plugins directory is where we keep all the jars of components that are used in the product. Patches directory is used to track the changes done to each jar. What it does is, when you add a directory (eg: patch0001/) and add a jar to this new directory (eg: patch0001/org.wso2.carbon.apimgt.api_9.0.174.jar), this will replace the same-named jar that is found in the plugins directory.
Before this replacement, the server will first backup all the jars that are found in the plugins directory to a new folder patch0000 inside the patch folder.
At each startup, server will first apply the jars in the patch0000 directory and start replacing the jars by increasing the counter of each patch folder. (eg: patch0000, then patch0001, patch0002 up to patch9999).
This is the difference between the plugins directory and patch directory. If you replace a jar in the plugins directory, this is not a backward compatible change. However, if you replace a jar using this patch mechanism, whenever you remove the patch0001 directory from the system, this change will be reverted and the original jar will be preserved.

How to upload dependencies jar in lib folder in apigee from Edge UI

I created one jar file and in that i have class files, .classpath file, .project file In sample on github, i see apiproxy, callout and lib folder. when i deploy it, i getting error that traffic can't flow , i get error like traffic.How to upload dependencies jar in lib folder However when i upload my main jar file in resources folder, i don't see any lib folder for dependencies jars. Should i place all jars in one resources folder. in my .classpath file, i can see all lib jars like message-flow-1.0.0.jar, expressions-1.0.0.jar and itextpdf-5.5.6.jar. However in documentation, its given to deploy by maven but i don't know maven, from UI how should i create lib folder and upload jars there.
Okay, in my understanding of your point.
You can upload jar file into apigee from Scripts > import file > in file type choose "JAR" > select jar file from your work space > and finally, define your jar name and then use policy Java Callout to call your jar.
If you have to modified your jar and want to deploy it, delete your existing jar in apigee and upload the new jar by following 1. In case of new jar has the same name of existing jar, you do not need to do anything with Java Callout policy. But the new jar has the different name, don't forget to modified Java Callout for refer to your new jar.
Please create the single jar file which contains jars like message-flow-1.0.0.jar, expressions-1.0.0.jar and itextpdf-5.5.6.jar. As per the apigee doc in create a Java Callout policy and make sure you have mentioned the package name & class name in Java Callout Poliy
<ClassName>package.ClassName</ClassName
<ResourceURL>java://SingleJar.jar</ResourceURL>

Using external libraries in Eclipse plugin

Problem:
I'm making eclipse plugin and need to use external jars.
What I did:
I maked folder lib where I added all needed jar and added them to the build path, but it's probably not enought, I found that I have to added them somehow to the plugin project dependencies, but I couldn't find how to add them in Eclipse. I use Eclipse 4.3.1 Kepler.
So I need use in my plugin something like foo.jar in which is fooClass.class.
Open the plugin.xml editor and select the Runtime tab. Add the jars to the Classpath section (bottom right).
This will add the jars to the Bundle-ClassPath entry in the MANIFEST.MF and will update the build.properties file to ensure the jars are included in the plugin.

How to add external Java libraries' folder to Jython project in PyDev?

I am completely new to Python/Jython/PyDev.
I just tried to add a folder containing JARs as an External Source Folder to my Jython project as shown here: https://stackoverflow.com/a/12583946/2018047
Unfortunately, imports only resolved when adding the JARs individually (instead of their containing folder).
Do I have to add something like __init__.py files to those directories to make it work on a per folder basis? How are the init files structured?

How do I create a jar file, which includes xml and html files?

I am trying to create a jar file which includes some class and java files needed, but I also would like to include some extra xml, xsl, html, txt (README) files.
I am using Eclipse on Windows XP.
Is there an easy way for me to set up a directory structure and package all my files into a jar?
Add the files to a source folder and they can be included in the jar.
One common way is to have, at the root of your project, a src folder. Within that, folders for java files, and others. something like:
src/
css/
java/
html/
images/
Then you can make each of those subfolders a source folder (Right click, Use as Source Folder) and they should be available to add to the jar.
A .jar is nothing but a ZIP archive, so you can use any program capable of creating ZIPs. Just make sure that you include the manifest and all the class files.
I just added all the files into my Eclipse project (including the txt, html, xml, etc files).
Then I used Eclipse to File->Export->Jar File->Next
Check the "Export Java source files and resources" box.
Done.
If you're using Ant, you can use the jar task (see the examples section for how to include/exclude certain files, etc.)
If you move to an ANT (or Maven, for you Maven fans) then you can automate the Jar building very nicely, and also use it outside of Eclipse (e.g., in an automated build environment). All you need to do is copy the files from your src, jsp, foobar and resources locations into a build staging folder, then Jar the resulting files using ANT's Jar task.
<target name="makejar" depends="compile, copyfiles">
<jar destfile="${jars.dir}/myjarfile.jar" index="true" basedir="${build.dir}" />
</target>
One thing I look down on is including non-source (except package.html files for Javadoc) within the src folder. If you feel you have to do this to achieve something, then you are doing it wrong.

Resources