How to make an uninstaller ( for windows ) in java,
i know the way how i should delete files, i just want to know how to put the uninstaller in the 'delete programs' section of the configuration screen,
Please do read the question, we do not want answers for software to make an installer, since we have already written our own program, we are a group of students with an interested spirit, so we wish to write these things ourselves, and don't want some software from someone else.
kind regards
jonathan
Please, do not write an installer by yourself. It looks deceptively simple, but isn't.
Either let the user launch your program through Java WebStart (which doesn't look like a Windows system but is acceptable for a central distribution model), or use one of the many existing installers which support Java.
Note: If you target enterprises, choose one that generates MSI. These can be centrally installed silently.
You should not have written your own installer in the first place.
Throw it away, and use a professionally-written installer generator to generate an installer (which will include the uninstaller.)
I recommend Launch4J, or for simpler installations (i.e. no custom install options) Java Web Start may be easier.
Izpack allows the creation of cross-platform installers with optional uninstall (under Add/Remove in MS Windows)
Or you can try non-free Install Anywhere
Java Web Start offers an uninstall facility. It also offers the ExtensionInstallerService which is intended to perform other set-up/pull-down beyond the standard 'cache or delete classes' (e.g. un/installing a DB).
Here is my demo. of the ExtensionInstallerService.
BTW - noting your further comments, I agree with the advice not to go that route.
Related
I've been looking around for an answer to this but haven't had much luck.
I've been working on a game in java that uses the javax.util.JavaCompiler class. I've discovered that this does not work with the JRE as I'll get a Null Pointer exception when I call the compiler run method (I'm assuming they simply don't ship a compiler with the JRE which is totally understandable).
My problem now is that my game inherently is dependent on the JDK. Is it possible to force my game to somehow search for the system environment variables and rather execute itself using the jdk?
I've tried using a separate launcher that then searches for the jdk and executes the game through that but that feels messy and I'm concerned there could be factors I'm missing.
It is technically possible, but it would make your application slow to start up to go an exhaustive search. AFAIK, there is no supported way to do this.
It is up to the user to choose how he / she runs a Java application. Doing clever things like searching for a JDK installation is potentially dangerous. (You could end up choosing an old insecure JDK that the user doesn't know about, or that they forgot to uninstall. That could open up the user to security breaches, etcetera.)
I would advise limiting yourself to a friendly message to the user explaining that they need to install and/or use a JDK.
You have the following options:
Check for the existence of that class during startup of your application; and if not found give your user a clear error message that he needs to run with a JDK (you would also specify that somehow as "prerequesites" on the site where people download your application).
Step back and carefully analyse which classes exactly your solution depends upon. And then you either repackage exactly those classes; or maybe you simply ship the corresponding JAR file with your application.
You see, asking your users to install a JDK is a big burden for them. Even when you are talking about some "inter-company" product where people have to use it ... few people are willing to install a JDK. And you absolutely should not expect that many users have a JDK installed.
On the other hand, when you consider re-packaging that stuff; you also have to look into the legal aspects; you don't want to violate any licence rules by simply handing out JDK related JARs to your customers.
You can simply put a try/catch block for the NPE around your use of the compiler API, and, in the event of the error, inform the user in no uncertain terms of the requirement.
Or, you can use asm or some other code generator package to avoid the need for the compiler.
Well I found the solution to the problem. Thank you to everyone who said I should package my game with a compiler. I found this post where the author describes rather using the eclipse compiler. Apparently javax.tools.JavaCompiler is just a common interface provided, I really should learnt the API in more detail.
You don't need to run your app with JDK. You can still run it with JRE. All you need to do is to make sure that a jar (from JDK or from anywhere else) that contains needed classes for your app is in your classpath. You can achieve it by including needed JAR(s) into your installation or by including the path to needed jars in your classpath parameter (-cp) when you run your app. If you want your app to run on computer where only JRE is installed you will have to include needed JAR(s) into your installation. think of it as any other third party library that you use and thus you have to package those libraries JARs into your application JAR/WAR
I need an advice here.
I need to create an installer for a Java application. After googling around a bit, I landed at these pages. After analyzing a little, I decided to go with IzPack. I found this nice blog post using which I was able to create a decent installer stub.
However I am now stuck with the further development. I need to customize my installer in several ways, and I am sure they're possible with IzPack, but I cannot figure out the ways to do it. The IzPack mailing list and its stackoverflow tag has a very low activity, and the documentation is very poor.
So I ditched IzPack, and started writing my own installer manually. After writing only two frames, I am realizing this will take much more time and might not be feasible.
Do you know of any other installer generator that has a better documentation and community support? Or do you know any good resources and links on IzPack where I can have my questions answered? Or do you suggest I stick with the custom installer approach? Please help.
You can try with install4j, it have a good documentation and commercial support ...
Another valid alternative to create a multi platform installer could be BitRock Installer (InstallBuilder) .
If you are running on windows, take a look at iexpress
To try it out press alt and simply type iexpress and press enter
Look to Java Web Start. It is cross-platform and has good support (on SO), as well as good support from the manufacturer (Sun/Oracle). I don't know if it fits the other requirements of this installation, but might know more when you specify those requirements.
I'm writing java swing app. I need my app connect to server CentOS 5.5, using username + *.ppk file (I don't have password). Then, my app execute some command line on this server.
Is this possible ? What library is best for it ?
There is a number of libraries that support what you're trying to achieve in different ways.
Connecting to an SSH server via Java is no big thing anymore these days.
Those are some libraries that you might consider:
Ganymede
http://www.cleondris.ch/opensource/ssh2/
Ganymede was made by some students at the ETH Zurich and works quite well. I personally use it in a project that runs on a very old machine using Java 1.3. It doesn't require anything besides a JRE. It is, however, not very active anymore. There is that company that seems to support it (Cleondris), but I wouldn't know how reliable they are. Doesn't matter much though since it's open source anyways. If you need to run your app on old java versions or need to know, that your app runs withou the Java Cryptography Extension (JCE), you could chose this.
JSch
http://sourceforge.net/projects/jsch/
JSch too is a mature piece of software and just works. If you've ever used ant to do SSH/SCP related tasks, you probably know it already. It's always a bother since you have to provide it to ant manually :-)
The project is well maintained, as it seems and widely used. I used it in a lot of modern UI/Batch applications and was/am always happy with it. It does use JCE though and I did once experience problems with that (on an older JRE, but still). If you plan to distribute your software to clients unknown to you, this might be a problem. JCE needs stuff installed / configured inside the JRE installation itself. Probably works 99% of the time, but still...
SSHTools
http://sshtools.sourceforge.net/
Never used this one but heard good things. May be worth a try.
Converting ppk to OpenSSH format using Java
As this is obviously possible, it's only a matter of implementing it. Fortunately for you, there are actually multiple implementations around. It might even be implemented in one of the suggested SSH libraries, but I didn't check.
A quick google search revealed two choices to me:
trilead-putty-extension
https://github.com/kohsuke/trilead-putty-extension
Seems to me like a very nice choice. Even though it's an extension to Trilead SSH library (which, it seems, isn't available anymore), it's not a lot of code and could easily be integrated into an existing project. There is one class that does the work and can convert a ppk key into a openssh one. String to string, so no surprises there. Should really be a piece of cake.
I don't know what happend to Trilead. The company doesn't mention it anymore on their website, but it certrainly existed at some point (http://techtavern.wordpress.com/2008/11/13/about-trilead-ssh-open-source-project/).
By the way: The guy who wrote it is the one who also wrote Jenkins/Hudson. http://kohsuke.org/
"ChillKat" Java Library
http://www.example-code.com/java/ssh_ppk_to_pem.aspn
Well... this just as an alternative. Doesn't seem worth the effort and overhead to download a "multi-purpose" library just for that. You could maybe extract the relevant parts or let yourself be inspired by it. Maybe the trilead extension doesn't work and you have to pick this one, but I wouldn't consider it first choice.
You can of course always convert the .ppk file manually, as explained here: http://www.lmolnar.com/geek/how-to-convert-puttys-private-key-ppk-into-opensshs-private-key-format-in-linux/
And other places, I guess. There is the graphical tool puttygen too, which is included in putty-installer or downloadable standalone via the putty website (http://www.chiark.greenend.org.uk/~sgtatham/putty/).
Would you like to know more?
Check this: http://linuxmafia.com/ssh/java.html or write a comment.
If converting the .ppk to a less proprietary format (i.e. .pub rsa or dsa) is an option, then give a try to puttygen (usage: "puttygen keyfile.ppk -o id_rsa -O private-openssh") from the putty-tools package.
Then use SSHTools, a java API for SSH (and more)
One of options is to use SSHBlackbox package of our SecureBlackbox product. It supports loading of Putty keys and full scope of SSH-related functionality (SFTP requires SFTPBlackbox package). SecureBlackbox comes with extensive samples and support.
The current JSch version does not support *.ppk files,
but JSch can use those files by using jsch-agent-proxy via Putty's Pageant.
Install and open puttygen
Click on "Load an existing private key file"
Click on menu item "Conversions" -> "Export OpenSSH key"
Save file, and use this in your Java app
I have been wondering for a long time about converting Java projects to EXE.
The advantages relies in the faster deployment on Windows where the user simply double clicks the EXE and the application is launched where is with Java, he has to run certain commands.
But EXE is really not what the Java was intended for which is portability.
So what do you think, Java to EXE good or bad idea?
I found some interesting article here.
Update
Wow, so may contradicting views so far. I would like you guys to add the pros and cons of the JAVA to EXE.
Since my expertise is with Java Web Start, which is for launching desktop apps. with a GUI, please consider my advice to be targeted mostly at those types of apps.
Other people have commented on the OS specific nature of an EXE. I always have to wonder why people choose Java to develop Windows specific desktop apps., since the Visual Studio software for Windows would probably make both GUI development (no x-plat Java layouts to bend your head around) and deployment (just guessing it can produce an EXE) easier.
OTOH only you can say what is the best development tool/language for this use-case.
As to the potential disadvantages of creating an EXE, I note at the JavaFAQ on EXEs.
There are a number of good reasons not to package your application in an executable. Daniel Sjöblom notes:
It will probably not be any faster. Modern virtual machines don't interpret bytecodes, they actually employ a JIT compiler to produce native, compiled code. Check Sun's site for further information on JIT compilers.
Static compilation increases the size of your application multifold, since all of the libraries you are using need to be linked into the application.
You lose 'free' upgrades to your program. Anytime your user downloads a new faster virtual machine, your app gets a speed boost. If you are using an exe, you will not get this benefit.
Jon A. Cruz details some of the extra steps in the development process required to create an exe. He points out that developers making native exe's need to:
Validate the latest versions of the compilation product from the vendor. If critical bugs are found, it can't be used to build a shipping product until those are addressed. Work that needs to be done each time a revision comes out from the vendor.
Submit the software through a QA cycle. Once engineering thinks things are done, they need to be verified. So every shipping version and update of a product needs to go through complete testing cycles.
Further, since native compilation is per target platform, the QA cycle needs to be done completely for each target platform, which multiplies effort required.
Shelf space. Maybe not a big deal nowadays, but could be.
Then one needs to get all customers to upgrade to the proper version. Either have free updates (in which case the business needs to absorb the cost of producing updates) or alternatively needs to handle clients not all updating.
Jon notes futher: When you ship standard Java bytecodes, VM problems are the responsibility of the platform or VM vendor. However, when you ship compiled binaries, they become your responsibility (even if they're actually bugs in the vendor's compilation product).
...
Of course, my first choice for deploying Java rich client apps. is using Java Web Start. Putting some of the benefits/features of web-start in point form:
JWS provides many appealing features including, but not limited to:
splash screens
desktop integration
file associations
automatic update (including lazy downloads and programmatic control of updates)
partitioning of natives & other resource downloads by platform, architecture or Java version,
configuration of run-time environment (minimum J2SE version, run-time options, RAM etc.)
easy management of common resources using extensions
..
I decided to highlight auto-update since with the gradual shift from apps. delivered on disk to apps. delivered over a network, auto-update is becoming more common. JWS still provides the best update experience (very configurable, mostly transparent to the user) I've seen.
And of course, JWS works on OS' for desktop PCs for which Java is available.
Update
..does Java web apps require internet connection?
(Note that name is 'Java Web Start'.)
Sure it does. At least for the initial installation. Update checks can be specified to continue to launch the previously installed version of the app. if the user is not currently connected.
But then, (in my estimation) there are more machines (such as Netbooks) with no CD/DVD drive, than there are without internet connections. If you want to sell to the larger market, look to the network to deliver the app.
It depends on your needs. We had written a little barcode client scanner app here for our customer. They run it on two Windows-PCs. They are happy having their well-known exe-files. We coded it in Java and created an EXE-file for them.
Both parties are happy with it - so why not doing it?
When there are good reasons for it and nothing against it except dogmatism then it is ok in my opinion.
I am the author of the article you linked to - glad you've found it interesting!
As my article states, and as others have already pointed out in their answers, there are multiple ways to simplify deployment of Java apps - JNLP, EXE wrappers, installers bundling a private JRE, and so on. But true native compilation is the only option that also provides protection against Java decompilers - you simply do not ship the bytecodes.
Of course, that does not make reverse engineering of and tampering with your code impossible, just much more costly in terms of required skillset and time.
As far as application performance is concerned, native compilation can make a big difference if you target embedded systems. This also applies to memory and disk footprint, albeit to a smaller extent. On the desktop you would typically get better startup, but in most other scenarios and aspects the results would depend on your app.
If it has a good reason why not? Even Eclipse has an EXE on windows and (and platform dependent binaries for linux, mac, etc) Of course you loose portability but if that is not important then go ahead.
UPDATE
The question is what do you want to achieve by creating an exe :
Convenience : users on windows prefer to click on icons, this is especially true for the non geeks. On the other hand non geeks don't care what the link does internally if it starts up an exe or something else. You can have an application icon for non native Java applications too. The alternatives would be
Web start
Creating an installer package,e.g.: http://www.advancedinstaller.com/java.html This can also solve the problem of installing the JRE
Performance : If you compile your Java application into a native solution you may gain a bit on performance but it depends on what technology you use. For example Swing tends to be slow but compiling that to native is rather tricky. If you use SWT instead of Swing that is already using native components therefore no need for further native compilation. On the other hand recent JVMs perform very well and can compile java to native to further improve the performance bottlenecks. This is done silently on the background you dont need to worry about that.
Sum : in some cases it might be the only solution, but if you choose the right technologies there will be many Java based alternative solutions to reach the same goal.
The page behind the link in the question is written by a company that sells products that compile java to native code. I would not base a decision on that alone.
The question also says that the advantage of the exe a better user experience, because the user can just double click to launch the application.
That is possible with executable jar file. In fact, its actually quite easy with standard tools in the java runtime. You just have to add a manifest to a jar file, and specify the class with the main in it. You can also specify other jar files in the classpath relative to the location of the main jar file. You can also specify an image to use as a splash screen as a resource.
e.g.
Class-Path: lib/derby.jar lib/derbytools.jar lib/jcalendar-1.3.2.jar l
ib/joda-time-1.4.jar lib/log4j-1.2.14.jar lib/looks-2.2.1.jar lib/swi
ng-layout-1.0.jar
SplashScreen-Image: resources/splash.png
Main-Class: com.you.pkg.app.Main
The basic ant project in Netbeans will do all but the spash-screen for you if you use it. If your some reason you want to do all of that by hand, make sure you understand the format of the manifest file, its a bit finicky.
As Linux, mac., Solaris user I think this is bad idea.
If you want faster deploy on windows, just create installer.
Jar files provide many benefits including:
Compact: The whole application (i.e. all the class files) is stored in one archive file (which can incorporate image and sound files if required).
Ease of use: The application can be run by double-clicking.
Compression: The jar format allows you to compress your files for efficient storage.
Security: You can digitally sign the contents of a jar file. Users who recognise your signature can then optionally grant your software security privileges it wouldn't otherwise have.
I would not convert to exe.
Most Windows applications run from a .exe file (Word, Internet Explorer, FireFox, NetBeans, ...)
Java itself has no support for doing this as the executable file will then be platform dependent (i.e. it won’t run on Macs)
However, there are (free) applications that can do this for you.
Minecraft does it, so it must be a good idea!
All jokes aside, understand that it's not 'conversion' that you are looking for, but using a custom launcher. The article you linked does a nice job of explaining the different approaches and pros/cons of each. As a general idea, it requires the extra work of creating the launcher (and a different version for each different OS architecture), but it gives you a little more control (version checking is a nice feature, also you may update the application jar rather easily, like Minecraft does). Overall it's a good idea if you think it's worth the effort, and the (little) loss in portability.
Edit: the 'Custom Java Launchers And Wrappers' approach is the one that you should use if you don't need the really nifty extra features offered by those below it.
Depends on the user base. If they are tech-related in anyway then giving them a .jar file (which could be run by double click) is a good idea for mobility.
If your users are less techy but you still need it to run on multiple platforms then wrap it as exe for Windows and as .app for Mac.
Important: I would suggest making a script to wrap it into exe, so you run it each time you have a new version.
We run batch files on our OpenVMS Alpha and Integrity servers. Up until now they have been written in COBOL. As you can imagine there are many reasons why will not be able to maintain that process.
At the same time we have a team of developers that use Eclipse and know Java very well. Is there away to use Eclipse with OpenVMS?
Maybe it's because I don't keep up with COBOL, but I am not sure why you're convinced you have to abandon it. I realize it's not the "in" thing, but if you already have a large code base I'd think at least twice before switching to another language. If it's a lack of developers, I don't think you're going to run out that soon.
That said, googling Eclipse & OpenVMS gave this link:
http://www.sdtimes.com/SearchResult/32973
So it looks like you can still get Eclipse for OpenVMS from eCube. If I'm reading that article correctly, HP seems to want you to go the NetBeans directions. Personally, I'm still using Emacs (and not currently doing any Java), so won't make a recommendation; I just wanted to point out that there are other ways to develop Java than Eclipse.
I didn't find Java for VMS on Sun's site (someone feel free to correct me if you find it), but it looks like you can get the JDK from HP/Compaq at:
http://www.compaq.com/java/download/ovms/1.5.0/index.html
Edit: I meant, but forgot to say: Assuming you're using a JVM on the VMS side, you should be able to development with Eclipse on another platform, and copy the byte code to the Alphas.
Speaking from experience, if you do decide to rewrite your batch processes in Java I'd suggest you use a third party batching framework like Spring Batch instead of 'growing your own'.
Using a framework also constrains you to work within a standard and should provide non-functional requirements like re-runability, transactions and error handling.
We've (re)built a number of batch processes from various technologies to Java using a home-grown framework and I find we end up spending time on fixing/optimizing the framework rather than just focusing on the business logic.
Don't leave Cobol yet - call a-cobol-programmer-thinking-about-switching-to-the-modern-world and make a trade: you teach him Java, He maintains your legacy.
Shell scripts and java usually aren't a great mix. You may want to consider installing a JVM on your VMS servers, and using one of the JVM-hosted languages that handle that case better- jython, jruby, or groovy might be candidates to consider.
Eclipse relies on native Java extensions that do not appear to have been ported to OpenVMS. Don't give up though. Java runs on OpenVMS (at least 1.5 according to a Google search).
NetBeans has a Java only edition that should work on OpenVMS. On the NetBeans Download Page select the OS Independent Zip option for the platform.
Are you running the batch files on your OpenVMS system? If so, HP makes Java available for OpenVMS, not SUN; you will have to look at their site. You can develop your java code on a windows/linux machine and test it on your VMS system; you must be aware of the native extensions that you cannot use on the VMS implementation of Java.
Speaking with some experience in this area, I suggest developing with Eclipse on your Windows/Linux/Mac desktop, and pushing the code out to OpenVMS for testing/deployment. Eclipse won't run on OpenVMS because of some platform-specific components of its GUI.
Some caveats:
Make sure that you are using the same version JVM on your desktop as on OpenVMS.
The case insensitivity in OpenVMS can be a problem when using inherently case-sensitive Java .class files. Package everything in a .jar and deploy it that way.
The attributes on .jar files have to be set correctly or the OpenVMS JVM can't open them. The following command should do the trick:
SET FILE *.jar /ATTR=(RFM:STMLF,RAT:CR)
HP provides both a "fast" JVM and a "classic" JVM. Use the fast VM unless your memory needs are highly variable.
I realize this question is rather old, but I was shocked nobody mentioned this book covering Java on OpenVMS.
https://www.theminimumyouneedtoknow.com/java_book.html
What really matters when using an x86 editor on OpenVMS source is your file transfer software. OpenVMS (and many other midrange ASCII based platforms) use even though most PC developers say LineFeed Carriage Return, the data files typically store it in the other order.
You can read much more about that here:
https://www.logikalsolutions.com/wordpress/information-technology/most-text-editors-get-tabs-wrong/
Your file transfer software will need to perform text mode file transfer changing the line ending characters OR your editor needs to both use and respect the better systems line ending characters. I thought there was something in Eclipse (via plug-in) to handle this. Notepadqq claims to have something.
Note this: They use Eclipse for development, not just editing.
That means they are running and debugging in their own PC based Eclipse universe and that ain't how it's going to work on OpenVMS. They are going to need a terminal into the VMS system and it needs to be a REAL VT-100 terminal emulator, not the worthless free stuff. You can read a little bit more about that here:
https://www.logikalsolutions.com/wordpress/information-technology/diamond-edt-keypad-support/
and here
https://www.logikalsolutions.com/wordpress/information-technology/xterm-and-vt-emulation/
Depending on how old your system is, you might have Pathworks installed and running. Then a system manager can create a directory for each user that they can map as a network drive to the PC. This lets the PC user use the directory like any other network disk and it generally could be configured to handle the line ending issues with text files.
There is no way they can develop on OpenVMS using Eclipse. They can edit files then test on OpenVMS, but they cannot develop within the IDE which I suspect is what they really want to do.
The only GUI that ever existed for OpenVMS was DECWindows. You had to run it on either a VAXStation or a DS model Alpha workstation. I never heard of Eclipse being ported to it. In the latest port of OpenVMS to x86 there is no GUI. It is a server only OS.
Yeah, I spent two decades on the platform and even wrote this book for it.
Yes, there is a version of Eclipse that supports OpenVMS called NXTware Remote. It has support for Java and COBOL languages as well as Fortran, Basic and Pascal.
You can edit OpenVMS files using pretty much any editor, including Eclipse - just use Samba to make OpenVMS directories and files visible to desktops on the network. If you install Java for OpenVMS, then you've got folks using Eclipse, and compiling and running on OpenVMS.
As for ditching Cobol - why? There's still a ton of companies running it, and it will certainly last for decades more.