-2

I have created a java application run by main. My development is done by Eclipse on PC and I would like to run it on linux scheduled by cronjob. The application has dependencies. Some classes are self-created. Some are external jars. What is the most convenient way to compile it to include all dependencies and put it on the linux?

Thanks

2
  • 2
    In eclipse, there is an option to export your project as runnable jar file. You can use that to generate a jar file and run it using java -jar yourjarfile.jar While exporting your project as jar, you can specify the java file that contains your main method and it will automatically pack all your dependencies into that jar file. While exporting you will see certain options. Choose the ones that are best for you. Commented May 10, 2019 at 20:04
  • this answer should help. Commented May 10, 2019 at 20:10

1 Answer 1

1

You don't need an IDE to run an app. As a matter of fact, the IDE is completely out of the picture when you run.

You need to package your application appropriately.

If it's a cron job, it's probably best to package it as an executable JAR, with all dependencies inside and the META-INF set appropriately, so you can run it this way in a command shell via script:

java -jar YourPackage.jar YourMainClass

Maven can make this easy.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.