How to compile/update github java file - java

There is a working jar file on Github version 1.4 (https://github.com/ggodlewski/smux-anki-converter/downloads)
The original author has updated the code to versions: 1.5, 1.6 and 1.7 but they are not standalone working jar files but mere zip files containing:
.classpath,
.gitignore,
.project
pom.xml
and some of the folders contained in the working version 1.4.
Version 1.4 is about 7MB and the updates are only about 45kB each.
The project itself seems to be dead and I cannot get in touch with the author.
My question is: how do I make those updates work? How to update version 1.4 to 1.7 on my PC?
I have tried to figure it out using Eclipse import/export but I am not a programmer and I just don't know how to do it.
Please help.

You should be able to build from source as follows:
Make sure that you have a Java JDK installed. Java 6 or later is required, but I would advise Java 7 or Java 8.
Make sure you have Maven installed and configured. (If you need to use an HTTP proxy to access the internet, you will need to instruct Maven ...)
Use git clone <url> to create a clean sandbox.
Change directory to the sandbox.
Run mvn assembly:assembly to build. (That is what the README file says ...)
The first time you do this, Maven is probably going to download a lot of stuff from the Maven Central repo.
If it works, the built JAR(s) will be somewhere in the target subdirectory.
(Note: I haven't tried this myself. YMMV.)

Related

Can we build java application through build plagin of maven without installing local JDK

Can we build java web app through build plagin of maven without installing local JDK.
As we all know that we have plugins in POM.xml and maven is using them for different steps, So my question is that is it possible that I write java code with POM.xml file and then add build/compile plugins to that POM.xml file and then compile this code only through maven plugin instead of installing jdk locally ?
If this is not possible then what is purpose of adding build and compile plugins to POM file ?
The short answer, as #khmarbaise mentioned, is no. Building java applications without jdk is not an option.
Maven plugins solve issues, depending on the plugin they may move things, generate code or do similar things to make the real build possible. They do not in any way replace a jdk tho.

How to took up artifact version built with Gradle from sources

When using Maven, it's easy to look up latest version of SNAPSHOT artifact by going to parent's pom.xml:
https://github.com/apache/maven-compiler-plugin/blob/master/pom.xml#L33
But where do I look to get the same in Gradle?
For example I couldn't find any version in the sources here:
https://github.com/testcontainers/testcontainers-java
And if it's impossible, then why? How Gradle knows which version to build? Is this information external to the source code?
It depends on the project setup. The project you link to, according to their RELEASING.md, use the tag name for the version.
Create a new release on GitHub. The tag name is used as the version, so please keep the tag name plain (e.g. 1.2.3).
This is done by the Travis build script, .travis.yml, specifically the line
script: ./gradlew -Pversion=$TRAVIS_TAG release
Some projects will explicitly put a version=x.y.z in their gradle file, others will provide it explicitly on build (similar to the Travis script used).
The advantage of this setup is that the version is never in the script, and you can't get merge conflicts or accidental version overwrites on this.

How to use NaCl with Java under Windows

I recently found the library Libsodium and was glad that there are also Bindings for Java. Unfortunately, the libraries don't appear to work with Windows because they were developed for other systems.
How can I use the libraries under Windows (if possible)?
Are there any alternative libraries for Java?
On that page for other bindings, you find the Java binding is called Kalium. You'll see it requires Apache Maven. So I went and got that (at the bottom it explains how to install maven, but basically you just add some environment variables).
Now on to kalium, I got it from their abstract on github. I needed mvn clean install from the directory in order to install it in Maven. After changing directory to the unzipped Kalium folder I ran the specified command (which is telling Maven to get the files and install Kalium). This will handle the rest of the set-up.
Then it's just a matter of adding it as a dependency in your Maven projects as per the Kalium readme. As for libsodium: it is a library that works with MinGW, and VisualStudio in Windows. So if you want to do C/C++ coding you can use that instead. But for the Java binding it seems you'll have deploy it using Maven.

Using maven-release-plugin in Eclipse

I recently tried to use maven-release-plugin since it is apparently the recommended way of building and packages releases in the Maven universe.
However I wanted to use this within Eclipse, as the rest of my development workflow is Eclipse based. I normally run Maven commands via the m2eclipse plugin provided as part of Eclipse Juno (4.2)
I noticed a few oddities when I tried to run "release:prepare" within Eclipse:
Some extra files were created in the root project directory - "pom.xml.releaseBackup" and "release.properties". Do they really belong there? Have I got the release directories set up correctly? I wouldn't really consider these temporary artifacts as part of my source code tree......
The pom.xml gets manually overwritten with the updated release number. Eclipse warns you and is happy to reload the updated version - but is this generally safe?
The prepare ultimately fails giving the error [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.0:prepare (default-cli) on project clisk: Failed to invoke Maven build. Error configuring command-line. Reason: Maven executable not found at: C:\Users\Mike\git\clisk\EMBEDDED\bin\mvn.bat -> [Help 1] - presumably because I am using the built-in Maven excetable provided by m2eclipse rather than the command line. I guess I could install command line maven as well.... but is that sensible or will it just cause more problems?
Given these kind of issues, Is there a way to get maven-release-plugin to work smoothly within Eclipse, or should I just give up and continue to do releases manually?
I have been using release plugin, but only from command line.
Re. 1. The backup files that release plugin creates are needed if something goes wrong in time of preparing the release. You can always rollback the prepared release using release:rollback command. When you do release:perform they will be deleted.
Re. 2. The plugin changes the version number from snapshot version for example: 0.0.1-SNAPSHOT: to release version: 0.0.1. Then after release:perform release version is moved to the maven repository and release plugin changes version again to 0.0.2-SNAPSHOT. Now you can use you full released (tested) version in your testing or production enviornment and snapshot version for developping purposes.
Re. 3. I don't know what is causing the problem, but I don't see the problem by using release plugin from command line.
Also mvn 3.3.3 installs a mvn.cmd file, instead of a mvn.bat file in Windows.
You should copy mvn.cmd to mvn.bat
Well i know this link is OLD , but to help some on who reffers this link for the issue 3.
Install maven separately on to local Box and give the path of the installation under Windows->Preferences--> maven--> Installation. Also you have to define the same in the run configuration within the Eclipse.
Attached is a link that explains the same.
http://maven.40175.n5.nabble.com/Build-Failure-prepare-release-td510949.html
You might be able to overcome the error you mention by installing command line Maven and configure Eclipse to use that rather than the embedded one by choosing Window -> Preferences -> Maven -> Installations, but I agree with the advice of making your releases outside Eclipse.

How to get java runtime source?

I am using maven, when I click some method of JDK from Eclipse, I received the error like
"Source not found". I am wondering how to get the source code of JDK from Maven?
Which class(es) are you attempting to look at? Assuming you installed a JDK and configured Eclipse to use it - and not a JRE, which doesn't contain the src.zip with the source code, this should work in most cases. An exception is for many (if not all) of the com.sun.* classes and others that are only available under the SCSL or the JRL licenses - which is available through a separate download from Oracle, after accepting one of these licenses.
I don't know what Maven has to do with this. You can find the JDK source in the src.zip that comes with your JDK. I don't know how to tell Eclipse to use it: I'm an IntelliJ user. There must be an attach source plug-in or command hidden in there somewhere. Point it at your src.zip and you're in business.
If you want to attach the source code of JDK, please reference Attach the Java Source Code
If the source you want to look is from third-party library like spring, you can tell maven to download the source code when you generate eclipse project
mvn eclipse:eclipse -DdownloadSources=true
But not all source can be download unless the source code maven artifact is published to maven repository.
Even more you can download Java doc with this argument when generating eclipse project
mvn eclipse:eclipse -DdownloadJavadocs=true
You can get more info from Maven Eclipse Plugin Link
Hope this will help you.

Categories

Resources