What Mailer for Play Framework 2.2? - java

Someone could reccomend me what mailer install on the new Play 2.2.1 (java)? And how to install?
From older questions I've seen that the TypeSafe one is developed by Play creators that it should be good about compatibility but it doesn't send email with attachments, and they don't specify the dependencies to use on Play 2.2. Another suggestion I found is Apache mail (this seems to send also attachments), but don't know if works on 2.2 and how to install it. I'm finding lack of documentation on this side.
I'd like a lightweight Mailer that doesn't install tons of library.

How to install:
For unmanaged dependency just download the binaries, unzip it and copy the required *.jar files into lib folder in your project (create it if doesn't exists).
Optionally if you can find required package in Maven repository, you can just add a managed dependency to your build file (in SBT format).
Both approaches are clearly described in the Play's dependencies doc.
Just tip: after adding dependencies, clean the build, update dependencies and re-create configuration for your prefered IDE if required.
Edit:
Here you've got all Apache's commons in Maven: http://mvnrepository.com/artifact/org.apache.commons
Just go to last version of required lib and copy required dependency format (from SBT tab in this case) and use as described in above docs.
FYI: Play already imports some commons libraries ie. lang3, others like io, email etc you can import additionally if required.

Related

How can I use JFlex if i´m cloning a project from github

i'm currently working on a Lexer in Java, i'm using jflex to do this, when my partner runs the code it works, he pushed it into a repo in github. I cloned it and when trying to run it, it says it cannot find a symbol which is Lexer, this is a class that jflex creates. I
I was expecting to be able to use the jflex library, which is stored in the lib directory in the project, also, in the .vscode directory we created a settings.json in order to be able to use it, we thought it worked but apparently when someone clones the repo it doesn't work. How can i solve this?
Download needed library
Commonly, projects uploaded to GitHub omit the various libraries needed by the app.
So you will need to manually obtain the needed library, usually a JAR file. Then place that JAR file in a location accessible by your project.
When deploying your app, you will need to either include the library within your app, or make the library available on the runtime computer.
Dependency management & build tool
Needed libraries are referred to as “dependencies”.
If doing any serious work in Java, I strongly recommend you learn how to use an IDE (such as IntelliJ, Eclipse, or NetBeans) in conjunction with a dependency management tool (such as Apache Maven or Apache Gradle).
Tools like Maven & Gradle will automatically locate a copy of your declared dependency libraries, automatically download from a repository, and then install within your project.
These tools (IDEs, and dependency managers) do come with a learning curve. But that learning time is well spent if you are invested in being a Java developer.

Amazon PA API 5.0 migration - Cannot find Maven SDK dependency (public repository)

I need to do Amazon PA API Migration on March.
I'm trying to find a Maven public repository where is published the 'PA API 5.0 sdk'.
This is the official documentation : link
It says :
Download paapi5-java-sdk-and-samples archive and unzip it.
Open the project in any editor of your preference.
Add all jars present in dependencies folder to the build path.
It's not professional and not maintainable doing like this..
Also many of these jars are old versions (2016 like).
I've tried to contact AWS PA API support but I've got generic response (read documentation etc.)
Suggestions? Do you know Java unofficial libraries? Thanks
Same here. There is only an old maven sdk available. I cannot even import correctly the jar on intellij idea. The IDE is able to find alle the classes needed by the examples, but on building it says: "error: package com.amazon.paapi5.v1 does not exist". I added the jar with this procedure
I have the same problem and totally agree that it's not professional and not maintainable at all.
My current workaround is just to integrate manually the paapi5-java-sdk-1.0.0.jar and then figure out what other dependencies were missing, and which one I don't need (for example junit-4.12.jar does not make not much sense for me when I just want to use it in production).
You might already having some dependencies in place that you don't need to add. For example you might already have Jackson. So don't add this to your pom.
All other dependencies that you need, instead of using the jar files, just add the offical repo of them to your pom as usual with the same version as you find in the zip file. That way you have the least manual dependencies as currently possible and are sure all additional dependencies work fine with the Amazon SDK.
In my case I just had to add okhttp, okio, gson, gson-fire and threetenbp from the offical repo.
You can use mvn install to install downloaded jar into your local repository. See here
https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

how to get all dependencies of a library?

I want to use the Google Firebase Messaging library in my Android Project. But my laptop just works offline and has not any access to the internet. I want to download FirebsaeMessaging library with all it's dependencies then add those files as aar library files to my project. First I want to get list of all dependencies of that library. How can i do this without internet? Thanks.
There are two approaches in general:
You download the complete dependencies with your online system, copy them into a libs folder and then create a project where you dependent on every jar in that libs folder.
You create a maven based project, build the project so that every dependency is copied to your local repository and copy the .m2 (local repository) to your offline machine. In case you want a gradle based project, #lance-java already posted a solution to that.
The first approach has the advantage that you have an isolated project with no dependency to the internet. Everything is in your project and explicit. You would have to check in your dependencies into your source control system like in good old times.
The second approach is good, if you are working in a team on that project. The export of your dependencies hat nothing to do with the project setup itself. Every programmer would find a "normal" project setup and dependency management.
If guess, that you want to go for the 1. way. If so, I would suggest to use ivy to download the complete dependency tree. Put the ivy-X.Y.Z.jar into your project beside a script that lists all dependencies - some sort of poor mans dependency management.
Example:
$ java -jar ivy-2.5.0.jar -dependency com.google.firebase firebase-admin 6.8.1 -retrieve "libs/[artifact](-[classifier]).[ext]"
This command would download the complete dependency tree for com.google.firebase:firebase-admin:6.8.1 and store the jars without version into the libs folder.
You could use my dependency-export plugin to export dependencies to a directory using maven directory conventions. You can then use the directory as a local repository for building offline.
As of Gradle version 6.1 the dependency cache is portable meaning that you can copy the dependency cache from one machine to another and the second machine should be able build offline. Perhaps this is what you want?
See this issue

How to properly use any Java API

I have been trying to use the vget library/api to make my own youtube video downloader. The vget library can be found here: https://github.com/axet/vget
I have downloaded the zip on github and I imported the project into eclipse. However, I am confused to how I am supposed to properly use this API. Should I make a completely new project, and import the classes that I need or do I put my own source files in the project of the api?
I have read other threads concerning this problem. However, they all mention how a api is typically packaged in a JAR file, but in my case it is just files and classes. So I am confused to how I should properly use this api.
The vget project is a maven project. You can see that because it has a pom.xml file in the root folder of the project.
To use it, you don't even need to download the source, because the compiled jar files are already stored in the central maven repository. You can find more information about this here:
http://mvnrepository.com/artifact/com.github.axet/vget/1.1.23
(in general, you can use the http://mvnrepository.com/ site to search whether your library is available on the maven central repository. If it's even a mildly popular library, then chances are that it is)
What you need to do is to make your own project a maven project.
Here's a "5 minutes" starter guide that describes how to do that.
When you've done that, you just add the dependency on vget to your pom.xml file in the <dependencies> section:
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.23</version>
</dependency>
Since you are making use of a 3rd party software, and not extending it with your own logic, the way to go is to create a new project, which references the 3rd party software.
You then construct your application and make it do whatever you need it to do. When it comes to using logic which is available within the 3rd party logic, you would then simply delegate that call to the 3rd party library.
I have seen on the link you have provided, that this is a maven project. You have to execute a maven package command, or maven install, so that the jar file will be generated.
With this jar follow the Bill's instructions, and add it as external library to your claspath.
When you do this, you will be able to invoke methods of that api.
Let us know if you need some help doing this in eclipse.
If your project is a maven project, you can solve dependencies problems just adding the dependency written on Readme file to your pom file.
The easiest and most automatic way is to use something like maven, ant, or gradle, that will automatically download and put the jars in to your classpath if they are in the central repositories. For example, in the maven configuration file(pom.xml) you can add this to the dependency list:
VGet Maven Repository
These build tools also allow you to add external jars if needed.
If
I would suggest you get familiar with Maven. At the bottom there is a Maven dependency you just have to include into your pom.xml, and then you can use the extension immediately.
Maven is a build platform which organizes your project in a technical way (convention over configuration, e.g. code is in /src/main/java, tests are in /src/test/java). The proper way is it to create a Maven project in Eclipse (you have to install the plugin and download Maven as well) and put the dependency
<dependency>
<groupId>com.github.axet</groupId>
<artifactId>vget</artifactId>
<version>1.1.23</version>
</dependency>
into your <dependencies> inside your pom.xml. After adding it, you project recognizes the additional package automatically.
Nobody tinkers by adding libraries manually. It's actually not professional to work without a build platform like Maven or Gradle.

Managing maven dependancies - New Versions and Non-Repo libraries

Warning: I have just picked up Maven, so things mentioned might be wrong or not best practice.
I have a medium size open source project that I am migrating to Maven from the basic
NetBeans project management. This is not a developer team sharing the same room, this is 1-5 people over the internet sharing a SVN repo. Reading over the how-tos on dependencies, it seems that the only way to get dependencies is to get them from an online repo or install them locally.
This is not what I was looking for. I want to keep all dependencies in the SVN for many reasons including portability (anybody can pass by, check out the repo, build, and use; all that simply without manual adding to local repo's and whatnot), getting newer versions (discussed below), and manual versioning.
The other issue I have with the maven repository is that they are quite behind in versions. Logback for example is 0.9.18 in mvnbrowser but 0.9.24 officially. PircBot is 1.4.6 in mvnbrowser but 1.5.0 officially. Why such old versions?
Issue 3 is that I have dependencies that don't even exist in the repos, like Easier Java Persistence.
So
How can I force all dependencies to come from /lib for example
On a related note, can mvn build from library's SVN repo directly? Just curious
Is there an automatic way to get the newest version directly from a dependencies site/svn repo if they also use Maven? IE libraries like commons-lang or logback
Is there a better way of managing dependencies? (IE Ivy or some weird POM option I'm missing)
FYI, this is a Java project with 3 modules, project global dependencies and module specific dependencies.
Bonus points if it can work with the bundled version of Maven that comes with NetBeans.
Not a duplicate of
Maven: add a dependency to a jar by relative path - Not wanting to install to local repository
maven compile fails because i have a non-maven jar - Don't think a System dependency is the right answer
maven look for new versions of dependencies - Still uses(?) repository, just the latest (old) version
This is not what I was looking for. I want to keep all dependencies in the SVN for many reasons (...)
I will come back on this but the solution I described in Maven: add a dependency to a jar by relative path (using a file-based repository) allows to implement such a solution.
The other issue I have with the maven repository is that they are quite behind in versions. Logback for example is 0.9.18 in mvnbrowser but 0.9.24 officially. PircBot is 1.4.6 in mvnbrowser but 1.5.0 officially. Why such old versions?
It looks like mvnbrowser indices are totally out of date (making it useless as repository search engine) because the maven central repository does have logback-core-0.9.24.jar (the logback project is doing what has to be done to make this happen) but only has an old pircbot-1.4.2.jar. Why? Ask the pircbot team. Anyway, you're right, the central repository might not always have ultimate versions.
Issue 3 is that I have dependencies that don't even exist in the repos, like Easier Java Persistence.
Yeah, this happens too.
How can I force all dependencies to come from /lib for example
As previously hinted, you should re-read carefully the solution suggested in Maven: add a dependency to a jar by relative path. This solution is not about installing libraries to the local repository but is about using a file-based repository (that could thus be stored in SVN). You might have missed the point, this matches your use case. And also check Brett's answer for a variation.
On a related note, can mvn build from library's SVN repo directly? Just curious
Didn't get that one. Can you clarify?
Is there an automatic way to get the newest version directly from a dependencies site/svn repo if they also use Maven? IE libraries like commons-lang or logback
Maven supports version ranges and you could use a syntax allowing to use "any version greater than X". But I do NOT recommend using version ranges at all, for the sake of build reproducibility. You don't want the build to suddenly fail because of some automatic update that happened on your back. Only upgrade if you need bug fixes or new features, but do it explicitly (if it ain't broke, don't fix it).
You might also find mentions of the LATEST and RELEASE version markers. I don't recommend them neither for the same reasons as above and even less since they're removed from Maven 3.x.
Is there a better way of managing dependencies? (IE Ivy or some weird POM option I'm missing)
Can't say for Ivy. But in the Maven land, if you can't host up a "corporate" repository for your project (Nexus, Archiva, Artifactory), then the file-based repository is IMO the best approach.
Setup your own Maven repository.
http://archiva.apache.org/

Categories

Resources