JAR executable pros and cons [closed] - java

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I have been using JAR files to export my projects in my Java subject at school. I noticed it's portability (assuming the computer in use has Java installed). However, with that fact, why haven't I seen developers distribute Java programs using a JAR file? What are the pros (besides portability) and cons (aside from using C++) of using the JAR executable?

There are two components to the question. The first is shipping a JAR and using no installer. The second component to the question is the pros and cons of a using just a JAR on the machine once the executable has been deployed. I'm starting to suspect that the OP was asking about the first component. My answer tries to answer the second component.
Pros
Less work. Don't have to make an executable for each platform you want to support.
Cons
If the user doesn't have java installed it can't tell the user why it can't run. An exe can also download java for the user.
If your app requires a specific version of Java it may run with the wrong version. A a native executable can locate the correct one and use it. This point isn't as important as it used to be since Java 6 has been around so long.
Can't have an customized icon for the executable on Windows.
You can't control startup options such as the maximum memory that your app can use. For most apps this is ok but sometimes you need more memory.
A JAR cant be used for a Windows service. There must be an exe wrapper around it (jsmooth has this).
Another alternative to producing an executable is to use JNLP. A web page can check for java before it forwards the user to the .jnlp file.

I'm hoping that the advantages are pretty obvious. The biggest disadvantage I've run into is when there are additional dependencies that are required that aren't included in the JAR. A MANIFEST can be included to set the classpath - but this requires that all of the dependencies exist with pre-defined names in a pre-defined location. This can be worked-around with a loader script (to set the classpath, etc.) - at which point not everything is contained in the single JAR anymore, and most of the advantages are lost.

Related

Is vagrant useful for java/javaee developers? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
When working with java/javaee usual development environment setup is to have everything locally (jdk installation, database, appserver etc). I know a lot of people in ruby/js world use virtual machines for development (mainly with vagrant).
I wonder if there is an efficient way to set up similar env for java/javaee.
I suspect that I can easily install database server and application server together with jdk version on such virtual machine, but what about regular development? I still need to have jdk installed locally, right? (I need my IDE to work properly) I need maven to build my project, so that I need full maven local repo. And then I need to deploy my app on virtual machine's app server.
I can see no real advantage here (still having pieces of environment on both machines).
Do you have any experience with that and can share with me?
Vagrant is basically a tool for setting up a VirtualBox virtual machine. It brings to the table the ability to quickly provision a VM and the ability to pass the provisioning recipe to others.
This is really useful in the Ruby/JS community because they don't have a compile step. The way we use it is the code stays on my local machine and all the runtime is done on the VM. If I make a change on my local computer the running program on the VM instantly picks up the change and the runtime is modified just as if the code was only on the VM. I literally don't even have to have Ruby/JS installed on my computer.
In the Java/.Net world you have a compile step so as you say you need Java and all the jars you need to compile against on your machine. This lessens some of the usefulness of the setup.
On the other hand you usually have databases, message queues, containers, etc. that you are working with and on a team it may be a pain to shoot an email and say update your db to this version and load the new sample data. In Vagrant only one person needs to make the updates and they can then tell you to grab the new VM and you do not have to do any of the upgrade steps yourself.
So it is still useful in a compiled language but it is less useful than in a scripting language.
It's not entirely clear what specifically you're looking for in terms of an answer.
IMO the value of virtual machines isn't so much for the development environment, but the runtime environment. Things like messaging/queuing, servers, databases, cloud servers (e.g., Swift), etc.
This is language-independent. For example, we have virtual machines (not Vagrant-based) that include Hadoop/HDFS/HBase, Swift, RabbitMQ, and a variety of containers.
We might deploy to those machines, but the dev tools are run locally. IMO there would be little reason to develop on the virtual machine, although there's no reason you couldn't, especially if you're comfortable with Vim/Emacs/etc.
I know there's a Tomcat container for Vagrant, although I haven't used it.

Forward thinking: Library Dependency handling in the workplace [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
At present my work is a little weird. I work on an unofficial engineering team that creates tools / solutions to problems that arise. A lot of our work is incrementally building on older work from team members for rapid development. But as our codebase grows there is an Informational management nightmare.
At present we're using Ant-Libraries and storing all the libraries for project in an "includes" folder. This means that we have lots of outdated / bad libraries for quick inclusion in projects. I've been looking into a way to incorporate something into Subversion that would keep our libraries up to date and would help get us standardized and up to date with minimal intrusion to workflow (editing pom.xml to make a maven project is somewhat intimidating to people that haven't worked with it before.
Does anyone know of any solutions that handle dependencies and allow simply uploading / downloading of libs / projects for team use / work?
Thanks!
It sounds like you just need a dependency manager. You already referenced one of the most popular, Maven. Maven is easier to use then it may seem. If you use standardized directory structures for source code and test source code, you can build/test/deploy with a single command.
Even if you don't use standardized structure, there are still benefits. My work's development shop also uses Ant for building and our build is very old, brittle, and immobile (lot of hard coded paths). However, there are ant plugins for maven that allow you to use Maven for just dependency management while still using your ant build scripts. This will allow you to eliminate the includes directory and just reference your pom file.
Maven Ant Plugins
Another option that I have heard about is Apache Ivy which works tightly with Ant. I have no experience with that though.

Is there a 'best' Java RAD - for al Android/Linux/Windows? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What's cross-platform for those, flexible, easy to develop and debug, and offers good cross-platform GUI development?
Good support for ODBC database is a plus and support for GIS database is a major plus.
Android does not use the same UI system as desktop Java. There is no common GUI tool amongst them.
As for Windows + Linux, both IntelliJ and NetBeans have a halfway decent Swing UI builder.
As mentioned by Yann, there are no cross-platform RAD system that cover both Android and Linux/Windows Java. Android is not really a Java-based platform; the Android SDK converts the Java bytecode to the more optimized Dalvik VM bytecode. For this reason, you may even find that even non-GUI java code does not "port" (I've run into a couple of such issues).
There exist some libraries that attempt to provide cross-platform access to the graphics layer such as libgdx, but none that will allow you to create "one-size fits all" GUI code easily. In general, though, you wouldn't want to do that either - the UI concepts are very different on a small touch screen and a large mouse-controlled desktop.
From a development point of view, any development environment that comfortably allows you to split the project into an Android project (for the Android stuff), a desktop Java project (for the desktop specific code), and a Java library project for the common functionality (keeping in mind the minor differences) that can be shared between both projects will do.
Currently only Eclipse provides a RAD environment for Android (as far as I know), but there is nothing to prevent you building the Android GUI part in Eclipse (importing the common code as a library) and doing the desktop project in a different environment if you prefer Netbeans or others for that.
Good and reasonably priced rad for android, basic language, native compile is Basic4Android google it, it was released a few weeks ago.
How about http://www.wavemaker.com/
and http://openxava.org/ ?
That comes quite close IMHO
and both are open source.

Java Application Installers [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm not looking for java-web-start, I'm looking for a thick-client application installation toolkit. I've got a stand-alone application that consists of several files (jar files, data files, etc) and would need to do some pretty standard installation tasks, like asking the user for target directories, have them locate some parts of their system - choose some of the per-machine or per-user configuration options and possibly try to detect some of the machine settings for them.
I'm looking for something which is like the MSI or other wizard driven installation applications. What's a good installer for Java? It would be ideal if it were cross-platform capable (Linux, Mac OSX and Windows).
Not an MSI-Installer but crossplatform: izPack
It's xml-file based with it's own GUI or ant task (whtaever you prefer)
Launch4j -- open source -- http://launch4j.sourceforge.net/
InstallJammer -- http://www.installjammer.com/
If you are looking for an Open Source solution, take a look here:
http://java-source.net/open-source/installer-generators
I have used InstallAnywhere and I think that it is a good solution too.
Although it is not Java-based, about half of our customers use BitRock InstallBuilder to package Java applications. It is cross-platform and supports all the OS that you require (Linux, Windows, Mac). The installer is native, so there are certain advantages to it, such as not requiring a self-extraction step or the need to bundle a JRE, so the installers tend to be smaller in size
AntInstaller enables you to create cross-platform installers where the installation itself is performed using an ANT script. The GUI is configured with an XML config file.
We used it to create quite complex installers. For complex GUIs however, the configuration can get very difficult. The next time I would probably try izPack because it seems to support ANT as well but has nicer GUIs.
I suggest izPack
with
packJacket
The Nullsoft Scriptable Install System NSIS (originally used for winamp) creates really nice installers for windows, and it's very powerful. It has a compiler that runs under linux, but the resulting installer is windows-only, unfortunately.
It's pretty heavy-weight, but worth keeping in mind if you might have to do any vaguely complex or non-standard things during installation.
I have used it since it integrates nicely with my (linux) build system, and I'd want to use packages for installing on linux anyway.

Best technology for adding plugin support to a J2SE application? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm writing a J2SE desktop application that requires one of its components to be pluggable. I've already defined the Java interface for this plugin. The user should be able to select at runtime (via the GUI) which implementation of this interface they want to use (e.g. in an initialisation dialog). I envisage each plugin being packaged as a JAR file containing the implementing class plus any helper classes it may require.
What's the best technology for doing this type of thing in a desktop Java app?
After many tries for plugin-based Java architectures (what is precisely what you seem to look for), I finally found JSPF to be the best solution for Java5 code. it do not have the huge needs of OSGI like solutions, but is instead rather easy to use.
OSGI is certainly a valid way to go. But, assuming you dont need to unload to reload the plugin, it might be using a hammer to crack a nut.
You could use the classes in 'java.util.jar' to scan each JAR file in your plugins folder and then use a 'java.net.URLClassLoader' to load in the correct one.
If you are "just" needing one component to be pluggable, it's enough to simply instantiate the classes based on meta information, e.g. read via a classloaders META-INF/ information from the various jars that are on your classpath or in a certain plugin directory.
OSGi on the other hand provides means to structure your whole application. If you already have a large Desktop application that needs one part pluggable, this would be a steep learning curve. If you start blank with what will be a Desktop app, OSGi provides means to modularizing the whole application. It's about "isolation of components" and independence of modules.
Apache Felix provides a nice start if you want to go down OSGi lane. It might look complicated and heavyweight, but that's only because one is not used to that level of isolation between modules. It used to be so easy to just call any public method...
Did you think of using OSGi as a plugin framework? With OSGi you are able to update/replace, load or unload your modules on demand.
One approach I'm considering is having my application start up a lightweight OSGi container, which if I understand correctly would be able to discover what plugin JAR files exist in a designated folder, which in turn would let me list them for the user to choose from. Is this feasible?
I also found this article by Richard Deadman, but it looks a little dated (2006?) and mentions neither OSGi (at least not by name) nor the java.util.jar package

Categories