Running a JAR file with cron on server? - java

I have written a java program which does some calculations then sends an email. I have packaged it as a jar. I need to run this program every week at midnight on Thursday. The chances are my computer is not going to be on all the time so I'll need it to run from some host. My question is - Is there a free hosting place which supports cron and java?
Hmm, I had a look at app engine but got stuck trying to install the Google plugin for eclipse. It brought up an error after clicking to install..
Cannot complete the install because one or more required items could not be found.
Software being installed: Google Web Toolkit SDK 2.4.0 2.4.0.v201208080120-rel-r37 (com.google.gwt.eclipse.sdkbundle.e37.feature.feature.group 2.4.0.v201208080120-rel-r37)
Missing requirement: Google App Engine Plugin 3.1.0.v201208080120-rel-r37 (com.google.appengine.eclipse.core 3.1.0.v201208080120-rel-r37) requires 'bundle org.eclipse.wst.sse.core 0.0.0' but it could not be found
Cannot satisfy dependency:
From: Google Plugin for Eclipse 3.7 3.1.0.v201208080120-rel-r37 (com.google.gdt.eclipse.suite.e37.feature.feature.group 3.1.0.v201208080120-rel-r37)
To: com.google.appengine.eclipse.core [3.1.0.v201208080120-rel-r37]
Cannot satisfy dependency:
From: Google Web Toolkit SDK 2.4.0 2.4.0.v201208080120-rel-r37 (com.google.gwt.eclipse.sdkbundle.e37.feature.feature.group 2.4.0.v201208080120-rel-r37)
To: com.google.gdt.eclipse.suite.e37.feature.feature.group 3.1.0

Check out Google App Engine:
https://developers.google.com/appengine/
It supports Java, and it's free within some quota.
Note that it does not support running desktop applications, but since you wrote your code in Java, it's most likely portable, and you can also take advantage of the App Engine platform services like sending emails. It also has a cron service.

Fire up an Amazon Micro Instance Server. They are free and give you complete control of the machine including setting up cron jobs.
AWS

Check out OpenShift ( https://openshift.redhat.com/app/ ).
The offer a free series of tools for small needs, and the ability to scale up from there.

Related

How do you develop with Intellij on Windows and Java and deploy to Azure Service Fabric

I'm using Intellij and Java, on a Windows development machine and Windows launch host target. The use of service Fabric has come into discussion but when I look at docs it presumes you're either using Visual Studio (and probably C#) and building/deploying to Service Fabric as SF project, or that your linux developer using eclipse and want to package to deploy to Service Fabric.
Intellij Azure tools doesn't look like it supports Service Fabric. The Eclipse Service Fabric plugin says it doesn't work in Windows (Linux only)
So how can a Windows/Java developer build and deploy to Service Fabric if you don't want to move to Visual Studio, change language, but you want to dev in Windows with Java?
Has any one found a simple way that this can be achieved?
I'd prefer NOT to have to jump off Intellij, definitely want to use Java (and Spring Boot), and interested in how I package and deploy to Service Fabric on Windows dev laptop (local 1 node cluster, Azure multinode cluster later).
Microsoft's documentation for Azure Service Fabric has a section on manually packaging an existing EXE (editing the XML configuration files) along with the Powershell scripts to push the package out to Azure.
I would think in most cases, the initial set up of the XML files and Powershell scripts would be a one-time thing and then you just re-use them for each deployment.

GAE multi-module, multi-language application on localhost

I have a multi-module GAE Application that is structured like this:
a Python27 module, that is a regular web application. This Python app uses the Datastore API. Regular, boring web app.
a Java module (another web application) that hooks on the Datastore calls (calls made by the Python web app), and displays aggregated data about the recorded Datastore calls.
I have been able to deploy this application on the GAE cloud, and everything works fine.
However, problems arise when I want to run my application on localhost.
The Python module must be started using the Python SDK. The Java module must be started using the Java SDK.
However, the 2 SDK's do not seem to share the same datastore (I believe the 2 SDKs write/read to separate files on disk).
It seems to me that the 2 SDK's also differ in the advancement of the Development Console implementation.
The Python SDK sports a cleaner, more "recent-looking" Development Console (akin to the new console.developers.google.com console) than the Java SDK, which has the old-looking version of the Development Console (akin to the old appspot.com console)
So my question is, is there a way to boot 2+ modules (in different languages: Python, Java) that share the same Datastore files? That'd be nice, since it would allow the Java module to hook on the Python Datastore calls, which does not seem to be possible at the moment.
You might be able to do something similar by using "appscale" (an open source project that could be able to help you, if you setup Virtual Box and load the image on it). Look at community.appscale.com
Another way (mind you, this is tricky) would be to :
1- deploy your python as a standalone project on localhost:9000
2- deploy your java as a standalone project on localhost:8000
3- Change your python and java code so that when they are in Dev, they hit the right localhost (java
hits localhost:9000 and python hits localhost:8000)
4- Try, like #tx802 suggested, to specify a path to local_db.
I am not sure either method works, but I figure they are both worth trying at the very least.

Does OSGi-as-a-Service exist?

Are there any Java PaaS solutions out there that offer OSGi containers as a service?
Google App Engine --> has their own GAE server which is modified Jetty
CloudBees --> has their own RUN#Cloud container which is modified Tomcat
OpenShift --> uses JBoss/Wildfly
??? --> uses, say, Karaf or Equinox
If not a full-blown PaaS, just a clusterable/scalable OSGi host. Google turned up nothing, so I'm assuming there isn't anything like this. Thanks in advance!
(In contrast to the other answers:) No, there is no OSGi-as-a-Service in the cloud, yet.
I am currently writing my master thesis about porting an OSGi application on a PaaS, so I did my own researches about PaaS and OSGi. I did not find any satisfying solution based on OSGi in the cloud (however I did find other solutions ;). The problem is that OSGi is pretty unpopular and the cloud is notoriously trendy.
As the other questions mentioned, OSGi is a Java library. So you could set it up pretty much everywhere where Java is supported. But that would be more a IaaS solution as a PaaS solution (which you seem to look for, as you are asking for OSGi-as-a-service). You would need to setup a OSGi framework on your own and you would have no support for deploying bundles. Which degenerates this solution pretty much. So no, there is no special cloud offer for OSGi, despite there are many for Java.
However, there is a nice book called Modular Cloud Apps with OSGi from Paul Baker and Bert Ertman published by O’Reilly. The book describes their PaaS-like solution to use OSGi in the cloud. The basically setup a repository of OSGi bundles, where they stored all their stuff. Then they created a cloud image, which only contains an empty OSGi framework/server (just like Apache Karaf, but they wrote their own tool called Apache ACE for what reason ever...). They were able to boot those images and as soon as the machine was up, they just deployed the bundles from their repository to the instance (via a web interface).
There is also a video of their demo on youtube: https://www.youtube.com/watch?v=oN3jYKOQ1Tk
I think this strategy is the best PaaS-like solution you could get. But - unfortunately - this is not supported by any cloud vendor out of the box. But you could set it up on (for exmaple) Amazon very easily.
EDIT
There also exists a Build Pack for Cloud Foundry to setup a Virgo server which can run OSGi apps: https://github.com/glyn/virgo-buildpack
Take a look at Gyrex. It's not a service yet but can be used to build you're own OSGi PaaS cluster. It uses Equinox, p2 for provisioning and Jetty.
http://eclipse.org/gyrex
Disclaimer: I'm a committer and heavy user of it.
There is a commercial provider of OSGi cloud services - Paremus. They have 2 cloud products - Nimble and Service Fabric. You might want to check them out. The Nimble product is available in a limited free edition for trial.
OSGi can be used on pretty much any cloud provider that offers Java support, since it is essentially just a Java library.
The exception to this would be Google App Engine, since they don't just modify Jetty, they modify Java itself and remove the ability to create threads and classloaders, both of which are required for full OSGi support.
OSGi is basically a Java library that can run on a virtual machine that has a JDK/JRE support. But remember one stuff, out of the box support is what you are looking for and you need to customize the PaaS you choose to run your app. I think to do this, you need to choose the provider that is easiest to configure and scale. Try out Jelastic. It is easiest of the lot to cinfigure and get started. Check their jar uploads, and I think it will suffice your needs.
Let me know what you think and if this answer is of any help.
Surya

Automatic deployment in GAE from subversion trunk

My team is developing a Java application which is to be deployed on Google App Engine(GAE). Currently we use the eclipse-plugin to build and deploy the code in GAE.
However, I would like to automate(by using cron or svn-post-commit hook) this process so that the source code in subversion trunk is automatically deployed in GAE before each scrum meeting. I hope this would eventually reduce the load on our programmers and help them to focus more on the application logic.
Please let me know if this is possible with Java+GAE+Subversion
thanks in advance
It is possible. This is what I did with my project. I should also note that this question is similar with another stackoverflow question in Possible to integrate Google AppEngine and Google Code for continuous integration? and it provides several good answer that you could use.
That being said, my personal approach is to set up ant build for the eclipse project, and use Jenkins to automatically update the code from Subversion and build them up using the ant build.
You could then add a target using appcfg and macro provided by google to upload your built project to Google App Engine. More details of using Ant on Google App Engine could be seen in here.
A bonus point of using continuous integration tools such as Jenkins is that you could add automated unit testing using JUnit or your personal testing flavor. It will save your team lots of headaches in the long run.
I used python for GAE and there is a appcfg.py script with which one can deploy the code with one command as -
python appcfg.py update
This makes me think that for Java as well there must be some script from Google to deploy applications. If there is one, then what you are trying to do must be a simple command which be used a cron job.
Your team should use a Continuous Integration tool, e.g. Jenkins. This will solve your next problems too, which you may not thought over: it can be configured to run unit and integration tests before deployment. It has many options for version control system integration.

Play Framework application deployment

it's been a long time working on a play app & now comes the time to deploye it. that my first time so i'm kind of lost. which hosting compagny is the best & offer good pricing ?
I'll probably post a detailed instruction of what I did, but here's a quick 2-min general idea.
Buy an Amazon Micro Instance Virtual Server (costs around $11/mo) with a debian squeeze (6.0) image
$> sudo apt-get install sun-java6-jdk6
$> sudo apt-get install mysql5
~: wget <playDownloadURL>
~: unzip *.zip
~: set path to java, play
sftp/scp your source code to /var/www/<yourApp>
$> cd /var/www/<yourApp>
$> play start
~: (not actual commands but the concept)
and you are in business.
The creator company of Play Framework, Zenexity, propose a hosting solution dedicated to Play applications: PlayApps
It's probably the best choice since it is native Play hosting.
Otherwise, you can export your Play application as a classic war:
play war yourapp -o yourapp.war
Then, this war can be deployed on every Java server (Tomcat, Glassfish, etc.). For hosting a Java application server, you'll probably need a dedicated or virtualized server.
Another solution is to deploy your app on Google App Engine. But for that, you have to developp your Play application in a specific way. In particular, you can't use classic persistence. You have to use the Siena Play module to manage your entities for Google App Engine.
I don't know if Play apps can easily be deployed on other cloud structures. Maybe on Cloud Foundry since it supports Java application but I did not tested it and there are not deploy plugins yet for this platform.
You can look at this direction Heroku
Cloudbees, http://cloudbees.com, is an excellent choice. There is even a Play Framework Module for it.
http://www.playframework.org/modules/cloudbees-0.1/home
All of my Play! apps are hosted on Google App Engine, which is free for small sites. But you can host Play! apps on any Java web hosting provider.
In this question Experiences on free and low-cost hosting for play framework applications?
there are several cloud options for play framework...
There are a number of cloud hosting solutions supported by Play. There is a module for Stax, and the message boards have mentioned success on several others. A quick search for 'deploy' on the google groups will show a number of options.
I would recommend PlayApps though, It is actually hosted on Ghandi (i think!) and the pricing plan is the same, so the Zenexity guys actually make no money from this. They have set it up to be a convenience to us developers.
GAE is an option, but it restricts what you can do with Play. The WAR file deployment option, allowing to deploy to any java servlet container is also an option, but adds the overhead and resource of the container unnecessarily, so again, not the best option.
You could try Play! Manager. It's a Manager for Play Applications much like the Tomcat Manager. Worth trying:
https://github.com/mbarbieri/playmanager
Lately I've been playing around with openshift for hosting playframework application
It looks really good, you have mysql, phpmyadmin, mongodb, mongorock, jenkins, and what's even more important, you get 5 applications with 500MB op data space for each one... for free...
I'm also using this play module to ease deployment to openshift
https://github.com/opensas/openshift/blob/master/documentation/manual/home.textile
have a look at these articles:
playlatam.wordpress.com
detailed github tutorial
article found at openshift's site
If anyone is interested on uploading on Linode please follow this thread.
Linode 512 and play! framework
I advise you to have a look at http://www.playframework-cloud.com
This PaaS platform can automatically scale up and down your application regarding your traffic. You can also finely customize if you want vertical, horizontal or both types of scalability. The consequence of this scaling is that you pay as you go : you only pay for your real consumption and not the potential one.
Deployment via git.
Non AWS, hosted in tier-4+ datacenters.
Free trial !
For AWS Boxfuse offers a very easy solution.
With Boxfuse's native Play 2 support you can now simply execute
boxfuse run my-play-app-1.0.zip -env=prod
and this will automatically:
create a minimal AMI tailor-made for your Play 2 app
create an elastic IP
create a security group with the correct permissions
launch an instance of your app
All future updates are performed as blue/green deployments with zero downtime.
This also works with Elastic Load Balancers and Auto-Scaling Groups and the Boxfuse free tier is designed to fit the AWS free tier, which effectively means that you can deploy your app at no cost.
You can read more about it here: https://boxfuse.com/blog/playframework-aws
Disclaimer: I'm the founder and CEO of Boxfuse
I would look into cloud hosting.
If you developed your application in .NET, look into Windows Azure.
Otherwise, check out Amazon EC2.
Little confusing to setup if your a firs-timer, but they have guides and stuff to help you through it, and you get 100% scalability going with the cloud.

Categories

Resources