I was reading a tutorial about java encryption using the DOM, and I cam across a strange case of a package javax.xml.crypto.enc.* not existing. I had heard that not all packages were shipped with the standard JDK, and instead needing to be downloaded as separate modules and imported into the project, is this one of these cases? If so, where can I download it?
I just did some research about the package, and it turns out that it was a part of, the now withdrawn, JSR-106: XML Digital Encryption APIs. http://jcp.org/en/jsr/detail?id=106
Related
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...
I am new to Java and trying to learn more about it. I studied the documentation and found the following for Java,
Java Docs
Are the packages listed here the same as standard libraries?
Yes. That is the library that Java's creators have provided.
here is a list of things to know:
java.lang is for all the basic classes that are actually imported automatically
(implicitly) because it is all the basic ones (String, Integer, Double, etc)
java.util contains all your data structures you learned in school and more. Read the documentation, and the more you know and practice, the better
java.io for file reading. Look into java.util.Scanner for simple file reading, but for any more complicated, low level file reading info, use java.io, its built for efficiency, while Scanner is for simplicity
java.math if you ever need to use arbitrary precision values (built-in in python, not in java)
java.net for sockets, connections, etc
javax.swing for GUI, which is an extension of the older java.awt
Hope that helps.
Yes they are the same. This library is also downloadable if you want to view it offline. Also there should be a src.zip file in your java installation files. On unzipping it you will find the source code of all the standard library classes.
Also the Java Language Specification should help you.
When you install Java, there will be a .zip file which contains the source of the standard library called, src.zip in root folder.These are the standard library.
In Java 9+, javafx replaces javax as the main UI library:
Is JavaFX replacing Swing as the new client UI library for Java SE?
Yes. However, Swing will remain part of the Java SE specification for
the foreseeable future, and therefore included in the JRE. While we
recommend developers to leverage JavaFX APIs as much as possible when
building new applications, it is possible to extend a Swing
application with JavaFX, allowing for a smoother transition.
JavaFX FAQ - Oracle.
Maybe my approach is wrong, but here is what I want:
A logging library, written in pure JAVA
It should work on Android as well
I want to use it in Android and desktop apps
The approach I tried is taken from VS and C#, there it is called "multi targeting" - it basically means a module shares source code with another module.
So my idea was to create 4 modules:
AndroidApp
AndroidLog
DesktopApp
DesktopLog
The "real work" on the logging stuff (most of the classes which are pure Android compatible JAVA) would go into AndroidLog (to prevent me from accidently using classes not in the Android SDK).
The Android App can use the log library without any problem, thats the way I do it at the moment. Now the DesktopLog should have some of the folders the AndroidLog has, basically reusing the same JAVA code.
I tried to add a source folder from AndroidLog to the DesktopLog, but I get an error telling me "the root already belongs to...". I am working with an SVN, but I think thats not the issue here (actually, I tried the above without SVN, but it might provide some workaround if there is no simpler solution).
So how do I get IntelliJ to:
Share JAVA files across different modules with different target platforms.
Thanks for tips,
Chris
PS: Search tearms are also welcome "sharing source JAVA" is not very google friendly.
mm. I think you're going about this the wrong way. I would organise it like this:
Common-Log - A common Java package containing classes which are used by DesktopLog and AndroidLog
DesktopLog, with a dependency on Common-Log
AndroidLog, with a dependency on Common-Log
DesktopApp
AndroidApp
Trying to simultaneously reference partial source trees from a single project in different sub-projects sounds like a recipe for headaches; I think you'll have more luck if you follow the approach of extracting the common support classes from both Logging projects to a separate common project.
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'm working on several Jython projects using libraries written in Java. I'd like to create some good documentation with Sphinx thanks to the autodoc extension. However when I try to create the html, I get errors because autodoc can't find the libraries written in Java:
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.0.5
loading pickled environment... done
building [html]: targets for 1 source files that are out of date
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] index
/Users/myName/myJythonProject/doc/index.rst:14: (WARNING/2)
autodoc can't import/find module 'myJythonProject', it reported error:
"global name 'PoolManager' is not defined",
please check your spelling and sys.path
where PoolManager is a Java class.
Could anyone help me to solve this problem?
Sphinx can be used to document Jython projects, but autodoc does not work for code written in Java. The autodoc feature imports and inspects Python modules. There is no support for doing the same with Java classes.
Implementing autodoc (or something similar) for Java seems feasible, but someone has to volunteer to do it. See this comment by Sphinx author Georg Brandl: https://www.mail-archive.com/sphinx-dev#googlegroups.com/msg03162.html.
I found some information about a proposed GSoC 2010 project aiming at implementing multiple language support for autodoc. But according to this blog post, the project wasn't completed. The developer chose to work on another GSoC project.
The sphinx-contrib repository does not contain anything related to autodoc.
Update
There is a new Sphinx extension called javasphinx that looks interesting. I have not used this extension, but according to the documentation, it can produce reST sources from Java code:
The javasphinx-apidoc tool is the counterpoint to the sphinx-apidoc tool
within the Java domain. It can be used to generate reST source from existing
Java source code which has been marked up with Javadoc-style comments. The
generated reST is then processed alongside hand-written documentation by Sphinx.
javasphinx makes use of another library called javalang.
PyPI packages:
https://pypi.org/project/javasphinx/
https://pypi.python.org/pypi/javalang