Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Compile and run Java Project with batch file or executable
Compile and run Java Project with batch file or executable [message #1796883] Sun, 21 October 2018 01:13 Go to next message
Rotciv Ocnarb is currently offline Rotciv OcnarbFriend
Messages: 2
Registered: October 2018
Junior Member
First things first, before confusing my question with "generate a executable file to my java project", thats not what i meant to ask.

The thing is, i want to compile and run my project (the same functionality as the "run" button on top of eclipse) with some executable or batch file, something i can pass to another program to execute it, and it will run my code.

Is there anyway to do this? My very small knowledge of Ant whispers to me that this could be done with an Ant Script, but i have no idea even where to start.

Does anyone can pass me some references or some information if that can be done, and how to do this?

Thanks in advance!
Re: Compile and run Java Project with batch file or executable [message #1797336 is a reply to message #1796883] Tue, 30 October 2018 05:15 Go to previous messageGo to next message
Jay Arthanareeswaran is currently offline Jay ArthanareeswaranFriend
Messages: 128
Registered: July 2009
Senior Member
If you are looking to do this with plain Eclipse SDK, one way I can think of is to export your project into an executable JAR file. Right click on your project from Package Explorer, Export -> Java -> Runnable Jar. Once you have the JAR file generated with the right Main class in the manifest, in most machines with a Java installation, you can simply open the JAR with Java. Or if you still need a script, simply add a batch file or shell script with "java -jar <jar_file_name>" to where you need.

Is this what you were looking for?
Re: Compile and run Java Project with batch file or executable [message #1797341 is a reply to message #1796883] Tue, 30 October 2018 06:17 Go to previous message
Sarika Sinha is currently offline Sarika SinhaFriend
Messages: 131
Registered: February 2010
Location: Bangalore, India
Senior Member
Ant Script can help in compiling, executing or call any other task.
Ant support for Eclipse can get you started -
https://help.eclipse.org/photon/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fconcepts-antsupport.htm


Sarika Sinha
JDT Programmer
Previous Topic:Import error in eclipse
Next Topic:Clean Project Before Running It
Goto Forum:
  


Current Time: Tue Apr 23 10:07:22 GMT 2024

Powered by FUDForum. Page generated in 0.03347 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top