Eclipse plugins as folders rather than jars - java

In eclipse tree or any eclipse based application.
I can see that inside the plugins folder.
most of plugins are in the jar format while some of them are in folders
and this folder is just the jar extract .
why someone could do this ? what is the benefit of putting a plugin as extracted jar rather than only jar file ?

You can do this to embed jars in the plugin that are used in classpath because yo can have issues with nested jars in classpath.
I think that you can also access resources differently. And it can be an easy (and dirty?) way to allow some customizations by overriding some resources such as images.

Let's say a plugin will need to execute an embedded OS dependent script on its start-up (ex. ".bat" script). If this plugin is installed as a jar, it will need to :
get an InsputStream of the embedded script
ensure it can write it somewhere (temp folder usually)
run the script
at the next start-up; check that the script has not already been extracted
...
Or, if this plugin is extracted as folder :
run the script.

Related

How could I have Eclipse export files into a different location than their source?

I am writing a Bukkit plugin in Eclipse in which I separate different functions into different packages and export each package as its own jar file.
However, I would still like to keep these packages in the same project, rather than separating them into different Eclipse projects. These plugins each have files which must be in the root of the jar file, such as plugin.yml. I have moved each jar's files into their respective packages, but these files are put into plugin.jar\com\Preston159\plugin rather than in the root of the jar file (plugin.jar\), causing the plugin not to work.
Does Eclipse have any function to make these files automatically compress into the root of the jar file even though they are contained within the package in the source, or, is this something that I could solve by using Maven? My current solution to this problem is to move the files manually after exporting the jar, but this is becoming increasingly annoying.
EDIT:
The project builder XML I ended up using to complete this task can be found here
You would need to use a Build Tool. There are several supported by Eclipse. Ant and Maven are now built-in, but there are several build tools that run directly within Eclipse, but Eclipse can also be configured to run an external build tool as well.
Do a quick search on build.xml for examples of ANT build jobs.
Unless you're specifically required to use MAVEN for continuous integration, etc. then what you want to accomplish would be easily done with ANT.

When running a custom Jar in Amazon EMR where is my jar run from?

All,
I am packaging my custom jar with all its dependencies, one of these conflicts with another jar on the EMR instance, so I want to add a step to set my classpath to the directory containing my custom jar, but to do that I need to know where that jar will reside on the various nodes and if there are any env vars that I can use to make these changes, if someone knows of a better way to resolve the root problem other than building against the same version of the jars on the EMR as that is not possible that would also be welcome input.
Thank you,
You can look at 'controller' log file to see where the jar file is copied to - and the hadoop streaming jar command run.
The custom jar gets copied to some folder under /mnt/var/hadoop (specific to the step). The only way this jar file would conflict with another jar is - if the it is under hadoop/lib - and part of classpath of 'hadoop jar'.
One solution is to use script-runner step to run the jar file instead of 'custom jar'. Here you may override classpath - set any relevant environment vars.
http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/emr-hadoop-script.html
This script may even run your customer jar using 'hadoop jar' command - in essence almost equivalent to running the custom jar directly.

How to create Jar file with external folders and Jars

I made a simple standard-lone java Application using Spring,Apache Camel,Activemq for processing messages.
Note: My Application don't have any GUI.
My project structure is in the following way.
SACLib folder have nearly 70 external jars(all Spring,Camel and Activemq corresponding jars).
It's working fine in Eclipse. SO Now We want to deploy into Jar file.I tried in Eclipse,But I didn't seen Rod1,Rod2,Copy1 and SACLib folders in my Jarfile.
after Deploying Jar, If I run FirstConsumer.java it runs Rod1-->ThMapInfratab1-2.exe file. For this I mention Real paths of .exe file.
How can I make Jar file with including all my folders.
Thanks
Well, this is a kind of work that is typically done with build automation tools like Apache Ant, Maven or Gradle, so you can investigate there if you want to make this happen automatically next time.
But, if you want to do it manually...
First, you project needs a META-INF folder where you will place a file called a MANIFEST.
That manifest contains a Main-Class entry pointing to you main class. You can read about this in the Java Tutorial: Setting Application's Entry Point.
But it can also contain a Class-Path entry, pointing to all other jars required by your application and that should be loaded by the executable jar.
You can read about it the Java Tutorial: Adding Classes to your Jar Class Path.
If you are building your executable jar with Eclipse, it will let you choose the MANIFEST file that you want to use during the creation process.
Now, if you want to use build automation tools, there are other answers here that explain how to do it:
Creating a bundle jar with ant
How to create executable jar with dependencies with Maven
How to export an executable jar in Gradle
simply using ant download it , and then make a build.xml file and put it
Here's an simple example of an ant target that will create a jar (named test.jar) that includes all jar files under the lib directory. Maybe this will solve your problem?
for using apache ant, see this
http://ant.apache.org/manual/using.html

Separating external jars from plugin lib direcory

I have a plugin that depends on external jar files.
I've made an update site to install the plugin into any eclipse.
These external jar files are shipped with the plugin.
I want to separate these external dependencies so that the plugin needs them during the installation and get them at the installation time. or search for them in a specific location away from the plugin jar file
Is that possible?
If so, How can I achieve that ?
Create separate plug-in's for each of the external jar's?
Like the way Eclipse handles things like Apache components.

Generating a Jar in Eclipse including external library

I have a java application I've written in eclipse. It works fine there.
It works fine run from a command line in the directory where I export it to. In that directory is another directory containing two jar files that I need for the application, and the manifest file has a Class-path option specifying them.
I want a way to use eclipse to generate the necessary file(s) to package this application to run on another machine. Is that possible?
If I choose "create executable jar file", it creates this huge file; it does unpack and repack the two libraries, which I know is one way to get their functionality included. I would actually prefer it if they were left as their own jars somehow, but I am not certain eclipse can do that. More annoying is the fact that the executable jar file option puts lots of files from my eclipse project into that jar file. I don't see an option to choose what gets included there, though I do see a place to enter inclusion and exclusion "rules' in the project properties. Do those apply here? Is there somewhere else I go to select what does and does not get included in the "executable jar"?
If I choose "create jar" (ins of "create executable jar"), I don't see where there's an option to include these two jar files anywhere. Perhaps there is no place to include them where they could be used.
If possible, I do not want to use Ant, I do not want to use Maven, I do not want to download another tool. It seems to me that Eclipse already has all this information and I suspect it can already do this without having to go and learn yet another "nifty" tool.
Eclipse has its own Jar export wizard for generate a runnable jar packed with required library or with the required library in a folder aside the jar.
Going in File ---> Export then choose Java - Runnable Jar
You can then choose how pack the jar and how handling libraries :
You can also save the ant script for later modification or use ...
You actually should use Ant or Maven for your task, I see no other option. Ant is already packed with eclipse, you only need to install a JDK, not only a JRE.
Ant is very easy to learn and you can find billions of examples in the internet. With ant you can do exactly what you want.
Maven is the more up-to-date way to build and package jars and do much more other stuff. Maven also is a good choice for you.
I'll second a vote for Maven. Eclipse has a decent maven integration (m2eclipse). Then check out this answer for building the jar effectively using Maven2
Building a runnable jar with Maven 2

Categories