Ankur Raiyani
Ankur Raiyani

Reputation: 1709

Google App Engine Deploy Only Jar File

I am beginner for Google App Engine.

I have simple java application with a class in which there is main method which executes some threads. Actually, it's Java application which is used to execute some back-end activities.

On my Linux server, i have created a cron job which executes this class at some specific time interval.

Now, I want to move this application to Google App Engine. I did search about that and what i find is i have to convert this java application to web application to deploy on GAE.

Please guide me how i can deploy JAR to GAE.

Thanks

Upvotes: 1

Views: 4305

Answers (5)

If you mean just a simple JAR with a main method, that won't work. Your application has to be a web service that responds to requests. Check this link to create an app using JAR file: APP-ENGINE

Upvotes: 0

Ankur Raiyani
Ankur Raiyani

Reputation: 1709

Finally ! i figured out the solution without using Google App Engine and just using Google Compute Engine.

I created a JAR and put it into my home folder using SFTP.

After that i created a cron file at /etc/cron.d/myfile as below

*/10 * * * * myusername java -jar /home/myusername/myjar.jar

Then i reload the crontab

sudo service cron reload

That's it ! Thanks for your input and interest !

Upvotes: 1

Raghvendra Kumar
Raghvendra Kumar

Reputation: 1388

Yes, you can only deploy web applications to Google App Engine, so you may have to convert your class into a Servlet class if you want to deploy it to App engine.

You can use the Servlet's url if you are looking to execute it as a cron job, so you can configure this url in a file cron.xml by specifying the frequency and time when cron job should be executed before deploying.

You can use the link below which will guide you through the steps :

http://www.vogella.com/tutorials/GoogleAppEngineJava/article.html

Google's documentation on Cron Job :

https://cloud.google.com/appengine/docs/java/config/cron

You can not however use threads when working with App Engine.

Upvotes: 0

hinson
hinson

Reputation: 151

Yes, your java application needs to be a web application. That is, you'd need to have a WEB-INFO directory within your jar, with the correct xml files (i.e. web.xml and appengine-web.xml).

Please, start by following one of the tutorials here: https://cloud.google.com/appengine/docs/java/gettingstarted/introduction

You also mentioned that you use threads in your application. I believe that on App Engine you cannot just create threads, and instead you need to rely on the provided threads api: https://cloud.google.com/appengine/docs/java/javadoc/com/google/appengine/api/ThreadManager

Thus, some of your code will need to be changed to use such an api.

Upvotes: 1

Andrei Volgin
Andrei Volgin

Reputation: 41089

You cannot deploy a single jar file to App Engine. You can deploy an application.

This tutorial explains how to create an App Engine project in Java:

https://cloud.google.com/appengine/docs/java/gettingstarted/introduction

Upvotes: 0

Related Questions