I'm looking for an update library for the software I am developing. It's a small software, but I'd like to imbue it with some nice features. One of those is auto-update. I've developed 2 class library to do this job for me, but I'd like a more robust library, becuase it's missing some features. Between the features the library could have, these could be in it:
Generate a difference file based on the old version (jar for example). Given the current version of the jar, and the new jar file, generate a new jar that will be downloaded by the clients, puting only the files that were changed since the last update.
Check some kind of checksum. Each file inside the JAR have it's own checksum, or the whole jar having a checksum.
Generate those checksum. If possible, while attending to the first item. File by file, or jar by jar, given the new files.
It would be nice if it could deal also if the input is a folder or a jar.
Merge the current jar with the downloaded one.
P.S.: I'm not writing a web-based (that runs in a browser) application.
Thanks for the attention.
Found the perfect solution for my needs in this answer: java web start alternative
Please take a look at this software https://code.google.com/p/getdown/ It claims it can be GCJ and be used to update also non-Java applications. But this does fills my expectations!
There are many possible ways of doing that. In fact, you already pointed what you need. While developing such a solution isn't a big deal, there are also many libraries and products that already do that.
Some examples are already stated in similar questions, like:
Autoupdate Feature in a Java Swing Desktop App
or
Design of auto-updating software
One example, out of a simple google web search is Autoupdate+
One thing to remember is that the install/update software doesn't necessarily need to be written in Java itself...
Related
I am using Eclipse + Subversion for Android development. I used to create a free version of my apps with ads, and another one payed without them, so I kept them in two separate branches on subversion.
The problem I have found is that as these are two different app for Google Play and other markets, they must have different package names. So I have, for example:
com.package.game
com.package.gamefree
When I do some changes on the free version of the game and want to merge them with subversion into the payed branch, I found myself in a trouble because source files for the free game are below com/package/gamefree and for payed under com/package/game
I ended up doing a "manual" merge, making a diff of source file by source file, but I also have to check those files that have been added into another directories and those that has been deleted. A waste of time.
So, is there any manner to make subversion know that com/package/game in one branch is the "same" directory than com/package/gamefree in the other?
Thanks a lot in advance,
I'm guessing here, but maybe you could have the free app on the trunk in the com.package.gamefree package.
On the branch you could have the other importing the one developed on the trunk as a dependency lib, and wrap it around with launcher class which is packaged under com.package.game, adding the license stuff...
This way you'll only have to modify the code once, and build 2 apps.
After googling a bit in deep, I found that my better chances was just two:
Using ANT in anny manner that automatizes the switch between free and payment versions at building time.
Using an Android Library project shared between two versions.
I have seen that most of the people using ANT were doing it some time ago by the lack of another option, but since there is Android Library projects on Eclipse/ADT this is the preferred way for this kind of things. Even in the development docs of Android, says:
http://developer.android.com/tools/projects/projects-eclipse.html#SettingUpLibraryProject
If you are creating an application that exists in both free and paid versions. You move the part of the application that is common to both versions into a library project. The two dependent projects, with their different package names, will reference the library project and provide only the difference between the two application versions.
This seems to be the best way for me also because I have never used ANT and given the library option there is no reason for learning it.
So I have done that way: my project is splited now into MyGameCore that is the library project with all common files to both MyGameFree and MyGamePay projects, that now just have the minimal classes needed to have a different main package name so Google Play knows they are different applications, plus the raw assets folder that according to Google Docs cannot be moved to the library. Anyway these are binary files that I simply copy from one version to another when they are changed, that is not very often.
So from now on, most of the time I just need to work on the MyGameCore project and the changes done have inmediate effect on both MyGameFree and MyGamePay projects without needing to merge branches.
This will save me A LOT of time and I will use it on my further projects from the very first code line.
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 am currently working on a project that utilizes the jfreechart library. I am currently using the jar file for this library by adding it in my build path. However I do not need the entire functionality of the library. I would like to carve out only those sections of the library I have used my code and obviously the dependent code.
My ultimate aim is to reduce the size of the project. I have to meet some size targets and using the entire 7 mb jar library is not an option.
I wanted to know if there is a way to do this apart from manually checking for dependencies?
I would ideally like to apply any suggested method to the jar file of the library but if there is a convenient way to detect unused code in the source code I am willing to import the source code into my project.
I apologize if my request is a repeat or a stupid question.
Thanks,
Sudipto
Unfortunately, you can't do this without (arguably) violating the JFreeChart license.
JFreeChart is licensed under the Lesser GNU Public License, and one of the tenets of that license is that the end-user should be free to modify or replace the licensed software embedded in your software. If you cherry-pick classes from JFreeChart and incorporate them into your JAR, you make it difficult for your users to exercise their right to replace the embedded JFreeChart classes. This is certainly against the spirit of the LGPL.
For more details, refer to the GNU LGPL and Java page.
If you want to do this kind of thing with JFreeChart, you will need to get permission from the copyright holder. If your supervisor is really keen to keep the download size down, a large cash donation to the JFreeChart project might help them come around to his way of thinking. (Disclaimer - I have no connection whatsoever to the project.)
This can indeed be hard to determine because execution paths of an application can differ per run. However there is the Instrumentation interface which can show you all the classes currently loaded by the JVM. That should give you an idea which classes to keep. As long as you have run all the possible outcomes of the application.
Generally speaking, this is of course a bad idea, but since you've asked...
I've had several classes - university level - on Java.
However, what these classes lack is some practical approach to Java - or, to programming as a whole. Things you can only learn in a business.
However, since I am not allowed to use Java on the workfloor, I don't get to learn this now - even though I would like to.
So I guess what I'm asking for is any number of plain have-to-know Java resources. Things concering, for example, what Ant is and why and how to use it; using revision control systems from your IDE; standard Java libraries you would use often ... Anything that would help with actual software development, really.
As some side information, I've been using Eclipse for about four years now, and I feel at home there.
I have a system that works fairly well for class assignments and for projects as well. Firstly, I create one Eclipse project per class. This way I can re-use classes from previous assignments. You can also customize your classpath by adding another project as a library.
I use the Maven plugin for Eclipse M2Eclipse. Not only does this give you the ability to search for libraries and add them easily but the exec:java plugin is an easy way to execute your code from the command line. It's helpful because when it executes your code, it uses a classpath that includes all linked Maven dependencies. If you aren't using external libraries, you might not need Maven but I've found it to be helpful to learn in preparation for the job market. It's fairly simple to start with plus there are a ton useful plugins for open source projects.
Next, for revision control I recommend Subclipse. You can get a free SVN account with a single login from Unfuddle.com. Link that up to your Eclipse environment and Import your project.
When I want to get a particular class specification, I go to Sun's Java documentation.
Another excellent resource that will certainly give you the reference material (searchable!) to answer any java question would be this torrent containing ~100 ebooks on Java, sorted by directory on various topics (like Ant, Eclipse, or Swing).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Where can I find some best practices for writing open source Java code?
I'm not looking for directions on how to write the code proper, but rather on distribution, packaging, documentation, and all the other aspects besides .java files.
My goal is to take a module I've written and publish it as open source.
Edit - I'm still missing direct, concrete instructions on what the zip file should contain. Are there conventions for this, or should I just pick some reasonable structure?
I'm not sure if there will be universal agreement on "best practices", but the items you mention might have easy answers:
Distribution is easy with java.net or Sourceforge. You'll publish your code using their standards,
Packaging will be ZIP files. It's a good idea to create an MD5 hash to make it possible for clients to check the integrity of their downloads.
Documentation - yes, lots please. Have separate javadocs and a reference guide that shows how to use your stuff.
Have a public SVN that allows anonymous access so folks can get and build the latest code on their own.
Have a bug tracker that allows people to report on bugs, new features, etc.
Set up a wiki for discussion, feedback, etc.
Maven has become something of an open source standard. Have a good pom.xml for those adventurous folks who want to check out and build your code.
Unit tests and good code coverage will help to demonstrate your commitment to quality.
I'll try to think of more.
See Karl Fogel's book http://producingoss.com/ - source available on-line.
If you're looking for specific directory structures, why not look at existing open source projects? I'd start with Jakarta Commons, which is a heavily used package.
Without any statistics to back me up, I'd say that many projects use a directory structure similar to that specified by Maven, even if they don't use Maven itself (and if you can get past the Maven learning curve, it is a nice build tool 90% of the time).
I am not adding that much, but I would suggest the following:
Directory structure
Try to make the javadocs complete, most open source modules or libraries don't have many javadoc comments. Generate the javadocs documentation and place it in a directory such as apidocs. If applicable in the javadocs, you should specify who is allow to call a class and in which circumstances the class/function should be called. Small code examples also don't hurt and are worth adding.
Add an "examples" directory to help
the developers/users use/integrate
your module.
Add a license files at the root of
your directory structure and ensure
that each of your file has a license
header.
Add a README file at the root
directory of the distribution for
general information and/or
specifics(link to the software,
author, help and support, installation
instructions, etc.)
Usually the source code goes into an src directories and the documentation goes into a docs folder.
Packaging
Try distributing your software into appropriate formats(zip, tar.gz, dmg, exe, jar, etc.). For example for a web application, I would have a zip, tar.gz, a war and maybe an ear. Depending on the website you'll be uploading to, you might be required to use an archive format such as zip.
Create an installer if applicable or not too tedious
Publishing
Follow the instructions if applicable to upload your module.
Advertise your module(Blog, Forums, Twitter, etc.)
Always make additional tests when packaging or uploading, something unexpected could occur(missing file, archive corruption, etc.).
I think it all boils down to automating the build-test-package-deploy cycle. Ideally, you should be able to do it with a single click (or with a single prompt command).
Personally, I use ant and define a deploy target which does the following
Builds all artifacts
Packages the artifacts into a single deliverable (.zip file)
Unzips the .zip into a local directory
Runs the test suite from that local directory
Uploads the .zip onto sourceforge
Having done that the only manual step is to define a new release via sourceforge's web-site.
Obviously, in order to make this procedure effective you must be test infected - I write tests for every new feature I am implementing.
If your project is named Foo, then version X.Y should be packaged in Foo-X.Y.zip and unzip to Foo-X.Y/.... (in other words, the path of each file in the archive should start with Foo-X.Y/)
Have a Foo-X.Y/README.txt containing basic instructions as a plain text file. It should at least contain information about where the full documentation is ("see docs/index.html for documentation") as well as brief instructions about usage ("add lib/Foo-X.Y.jar to your classpath") and rebuild instructions ("run "ant build" to regenerate libraries in lib and javadoc in apidoc/").
If your project requires additional libraries to work or compile, then automate that. I.e. either let this be a Maven project or ensure it works with Ant Ivy.
I would suggest having the source under src/, the built libraries under lib/, the documentation under docs/ - this is what people would expect.
Use Apache Maven 2 and you will get all the artifacts you need... with a simple command "mvn package site"
I would suggest SourceForge (http://sourceforge.net) for your project hosting as they have a wide variety of tools (blogging, wiki, source control options, etc) and it's all free.
As far as what to put in the zip/jar... it really depends on the type of project. If it's a reusable library, I would suggest that in the root of the archive, have your license, and your distribution jar. You could put dependencies in a lib sub-directory, with your documentation in a docs subdirectory.
An example would probably help you better... download the Jakarta Commons - Lang API (http://commons.apache.org/lang) and look at what they provide.
One of the other answers was to use Maven (http://maven.apache.org) to manage your project and I would also recommend this, though if you haven't used it before it can have a bit of developer learning curve.
Good luck and I hope this helps a little.
Book: Practical API Design Confessions of a Java Framework Architect (Jaroslav Tulach, 2008, Apress).
Besides the hints in the book, please do a proper documentation (comments, javadocs) and include usage samples somewhere public (preferrably in a wiki style). Usage might be obvious to the devs but not for the clients (See JFreeChart as an example).