I have started working on various open source frameworks like zookeeper, Hadoop, Solr. I have learnt their architecture . But when it comes to develop applications using JAVA API , where will i get the packages containing API that will be compatible with the version of framework . Is it like when i download the framework(Zookeeper) , the jar files (needed for API) also comes along with it. I am a beginner with java , and it might seem a silly question to all of you. Please help me out by sharing your knowledge.
Thanks
The depends on what tools you use. First, understand that if you "download the framework" as you state what you are doing is downloading the "jar files (needed for the API)". That is the only thing to be downloaded. In some cases there might be a core jar and an api jar but this is what constitutes the "framework" and what must be downloaded and added to your applications classpath.
That said, if you use a tool like Maven, it will take care of a lot of this for you once you add the framework as a dependency.
Related
How would you implement a Plugin-system for your Java application?
Is it possible to have an easy to use (for the developer) system which achieves the following:
Users put their plugins into a subdirectory of the app
The Plugin can provide a configuration screen
If you use a framework, is the license compatible with commercial developement?
First you need an interface that all plugins need to implement, e.g.
public interface Plugin {
public void load(PluginConfiguration pluginConfiguration);
public void run();
public void unload();
public JComponent getConfigurationPage();
}
Plugin authors should then bundle their plugins into JAR files. Your applications opens the JAR file and could then use an attribute from JAR manifest or the list of all files in the JAR file to find the class that implements your Plugin interface. Instantiate that class, the plugin is ready to go.
Of course you may also want to implement some kind of sandboxing so that the plugin is restricted in what it can and can not do. I have created a small test application (and blogged about it) that consists of two plugins, one of which is denied access to local resources.
Use OSGi.
It is the foundation of the Eclipse plug-in system. Equinox is Eclipse's implementation (licensed EPL) and Felix is the Apache Project's implementation (licensed Apache Public License).
Eclipse provides a concrete example that OSGi can cover the points you mentioned (or you could just build your application on top of Eclipse RCP if you want a full Eclipse/SWT/JFace stack).
Since 1.6, there's been java.util.ServiceLoader which can be used if you want to code your own simple system.
But if you want anything more than basic features, use one of the existing frameworks.
Use PF4J.
It has support for Web, Spring and Wicket.
Easy to use and build the applications
There is also JPF (Java Plugin Framework).
I worked on OSGi for a week--an intense, nothing but OSGi week. At the end it was like a bad dream but I learned a lot.
I was able to get OSGi working (not easy, all examples are out of date, everything on the net is at least three years old if not five), but I had serious trouble getting it integrated into an existing project because of issues with the jar manifests.
In short, there are only a few obscure tools used for building manifests and they are not well documented (BND Tools is hardly obscure, but it is designed for a certain process in Eclipse). Also, most of the OSGi information available is not targeted towards application developers who have an existing desktop application.
This makes a lot of the context for the information foggy or inappropriate. Neil Bartlett's blog posts were the biggest help, but even those failed to get a working system (I grabbed some code from the Felix tutorial and pieced it together to get the embedded framework rolling). I found his book draft that he posted for free years ago, which is excellent, but the examples in Eclipse do not work because of changes in Eclipse OSGi support.
I think that recommending OSGi for solving the above stated problem is extremely poor advice. OSGi is "the right choice" but for a scenario as the one above, I think either JPF or some homegrown minimalistic framework is sufficient.
Years ago I started a project like that and I hope soon will be ready.I got inspired by projects like NetBeans and Eclipse but meanwhile it changed to something a little bit different. OSGi looks like a good choice now, but I didn't had a chance to compare it with my project.It is similar with JPF mentioned above, but in the same time different in many ways.
The basic idea which motivated me is to be as easy as possible to build Java application, with no separation between web applications, desktop applications or applet/JWS applications(of course this doesn't cover the UI - yet) as a core functionality.
I built the project with a few goals in my mind :
it doesn't matter if you build a web application or a desktop application you should start the application in the same way, a plain main method, No fancy web.xml declaration(not that I'm against having a standard web descriptor, but it doesn't go well with a plug-in system, where you add "servlets" - I call them RequestHandler(s) - dynamic at your will).
easy to plug in "extensions" around an "extension point" - something from Eclipse but a different approach.
self-deployable, since all the plugins are registered(XML files) the application must be self-deployable independent of the build system - of course there is an Ant task and a Maven MOJO which are the links with the ourside world, but in the end it calls the application and instruct it to self-deploy itself at a specific location.
borrowed from Maven, it can download code from repositories(including Maven 1 & 2 repositories) so your application can be deployed as a single small jar as long as you have access to the repositories(useful sometime, and basically this provides support for auto-updates - don't you love the idea to be notified by your web application that there is a newer version, it was downloaded and it just needs your permission to install it? I know I love that).
basic application monitoring about system health, email notifications in case of failures
How would you implement a Plugin-system for your Java application?
Is it possible to have an easy to use (for the developer) system which achieves the following:
Users put their plugins into a subdirectory of the app
The Plugin can provide a configuration screen
If you use a framework, is the license compatible with commercial developement?
First you need an interface that all plugins need to implement, e.g.
public interface Plugin {
public void load(PluginConfiguration pluginConfiguration);
public void run();
public void unload();
public JComponent getConfigurationPage();
}
Plugin authors should then bundle their plugins into JAR files. Your applications opens the JAR file and could then use an attribute from JAR manifest or the list of all files in the JAR file to find the class that implements your Plugin interface. Instantiate that class, the plugin is ready to go.
Of course you may also want to implement some kind of sandboxing so that the plugin is restricted in what it can and can not do. I have created a small test application (and blogged about it) that consists of two plugins, one of which is denied access to local resources.
Use OSGi.
It is the foundation of the Eclipse plug-in system. Equinox is Eclipse's implementation (licensed EPL) and Felix is the Apache Project's implementation (licensed Apache Public License).
Eclipse provides a concrete example that OSGi can cover the points you mentioned (or you could just build your application on top of Eclipse RCP if you want a full Eclipse/SWT/JFace stack).
Since 1.6, there's been java.util.ServiceLoader which can be used if you want to code your own simple system.
But if you want anything more than basic features, use one of the existing frameworks.
Use PF4J.
It has support for Web, Spring and Wicket.
Easy to use and build the applications
There is also JPF (Java Plugin Framework).
I worked on OSGi for a week--an intense, nothing but OSGi week. At the end it was like a bad dream but I learned a lot.
I was able to get OSGi working (not easy, all examples are out of date, everything on the net is at least three years old if not five), but I had serious trouble getting it integrated into an existing project because of issues with the jar manifests.
In short, there are only a few obscure tools used for building manifests and they are not well documented (BND Tools is hardly obscure, but it is designed for a certain process in Eclipse). Also, most of the OSGi information available is not targeted towards application developers who have an existing desktop application.
This makes a lot of the context for the information foggy or inappropriate. Neil Bartlett's blog posts were the biggest help, but even those failed to get a working system (I grabbed some code from the Felix tutorial and pieced it together to get the embedded framework rolling). I found his book draft that he posted for free years ago, which is excellent, but the examples in Eclipse do not work because of changes in Eclipse OSGi support.
I think that recommending OSGi for solving the above stated problem is extremely poor advice. OSGi is "the right choice" but for a scenario as the one above, I think either JPF or some homegrown minimalistic framework is sufficient.
Years ago I started a project like that and I hope soon will be ready.I got inspired by projects like NetBeans and Eclipse but meanwhile it changed to something a little bit different. OSGi looks like a good choice now, but I didn't had a chance to compare it with my project.It is similar with JPF mentioned above, but in the same time different in many ways.
The basic idea which motivated me is to be as easy as possible to build Java application, with no separation between web applications, desktop applications or applet/JWS applications(of course this doesn't cover the UI - yet) as a core functionality.
I built the project with a few goals in my mind :
it doesn't matter if you build a web application or a desktop application you should start the application in the same way, a plain main method, No fancy web.xml declaration(not that I'm against having a standard web descriptor, but it doesn't go well with a plug-in system, where you add "servlets" - I call them RequestHandler(s) - dynamic at your will).
easy to plug in "extensions" around an "extension point" - something from Eclipse but a different approach.
self-deployable, since all the plugins are registered(XML files) the application must be self-deployable independent of the build system - of course there is an Ant task and a Maven MOJO which are the links with the ourside world, but in the end it calls the application and instruct it to self-deploy itself at a specific location.
borrowed from Maven, it can download code from repositories(including Maven 1 & 2 repositories) so your application can be deployed as a single small jar as long as you have access to the repositories(useful sometime, and basically this provides support for auto-updates - don't you love the idea to be notified by your web application that there is a newer version, it was downloaded and it just needs your permission to install it? I know I love that).
basic application monitoring about system health, email notifications in case of failures
I am working on a small Java Swing based application, and want to add a decorative feature in it to sync files with Google Drive. But, all the documentation / discussions about Google API's that I see talks about putting this code into a web application. Also, the credentials of the client on https://cloud.google.com/console require the origin URL, without which the API will not work.
I know I can either embed a Jetty or take the hard way of sending and receiving HTTP requests. But either would be an overkill for this petty application that I am making. So, I was wondering if there is a way to include a Jar file that just lets me login and then access the folders on the Google drive.
Do you know of one? Is this possible with the existing API's? Thanks for your help!
If you have a look at the detailed installation instructions then there is a section for general purpose java applications. That is your case.
The following are the jars from the dependencies folder required for general purpose Java 5 applications (or a newer compatible version of each dependency):
google-api-client-1.17.0-rc.jar
google-oauth-client-1.17.0-rc.jar
google-http-client-1.17.0-rc.jar
commons-logging-1.1.1.jar
gson-2.1.jar httpclient-4.0.3.jar
httpcore-4.0.1.jar
jackson-core-2.1.3.jar
jsr305-1.3.9.jar
protobuf-java-2.2.0.jar
xpp3-1.1.4c.jar
You can use the GooglePromptReceiver to ask the end user to paste the authorization code from the browser to your application. You can find examples in the samples. The cmdline samples apply to your case.
I have been working on a freeware application named "Cyberoam Iview" that has two modules, one written in C and the other in JAVA. Just for you know, this is an online application that requires JDK,PostgreSql database,Apache Server to setup on any host system environment.
I tweaked some changes to the available source-code according to my requirement. After the changes, I want to deploy this application as a one single packaged file, like in ".exe" format. All it's pre-requisites are required to be bundled in a single ".exe" format so that when I run that ".exe" file on my system, it installs and setup every application that it requires to run like installing Postgresql, setting up Apache server environment, JDK.
I read many posts and discussions, and thus tried my hands with CYGWIN tool to deploy the application, but failed to do so.
Suggestions are most welcome. Thanks in advance.
You can take a look at JSMooth. I use this for this purpose. You can create a standalone executeable and it even provides a downloader if no Java is installed.
I have some good experiences with IzPack installer and I can highly recommend it. You can check out my short and simple tutorial at Softwarepassion website - I guess a bit outdated tho.
You should be able to pack your jars and all external files as a single file
I need to mirror some websites from my Java application. I was looking for an open source java library to do this job, but didn't find anything suitable.
Does anybody know about some java-friendly tool to retrieve entire websites, or must I stick to exec wget from my program?
Thanks a lot.
The biggest problem I found with this kind of libraries was the lack of support for css parsing, so the imported stylesheets, background images and so on get downloaded as well when mirroring the website.
wget has built in support for this (at least in recent versions), and although it's not a very clean solution to run this program from java, I'd first try it and see if it fits your needs.
I would recommend a crawler/spider. Aspider and Sperowider use Apache HttpClient lib (my favourite httplib) and crawls through the site following links. Since they are OSS you should be able to integrate it into your software. They are also currently unmaintained, but Apache HttpClient lib would be a good place to start if you want to write your own mirroring tool in java.