6

So this may seem a bit vague, how quick is "quick" etc.

Well I'm just wondering if there is a way of exporting a JAR file in a quicker way than:

File -> Export -> JAR File etc etc.

Like can I Ctrl + Drag to explorer and it export with the project title and .jar?

Charles
  • 50,943
  • 13
  • 104
  • 142
RedJax
  • 123
  • 3
  • 10

2 Answers2

8

How to add custom shortcuts

To add or change shortcuts open: Windows->Preferences->General->Keys. Here you can find all the Eclipse commands and their associated shortcut keys.

Reference

You can add a custom binding in eclipse to export your jar using a keyboard shortcut.

Example

I added bindings both for Runnable and non-runnable jar:

  • Export Jar: CTRL+SHIFT+J
  • Export Runnable Jar: CTRL+SHIFT+R

enter image description here

How to do with Ant File

If you want the JAR to be generated automatically you can look at the following question:

How to do with Batch file run from Button

You can use the combination of the following two answers:

Basically create a batch file that makes the JAR... add a button that executes it.

Community
  • 1
  • 1
Menelaos
  • 23,508
  • 18
  • 90
  • 155
  • Is there any way to then make it so that it when I press those keys is names the file the project name and saves it in the previous location – RedJax Jul 16 '13 at 22:49
  • So you mean do a key combination and export directly in one step? – Menelaos Jul 16 '13 at 22:50
  • Maybe this will work for you: http://stackoverflow.com/a/12200309/1688441 . Otherwise, a custom eclipse plugin OR a button in your GUI that calls a bat file that does the jar export. – Menelaos Jul 16 '13 at 22:53
  • Yes that exactly what I mean – RedJax Jul 16 '13 at 23:00
2

If using Maven a long term option would be to set up your build to 'package' your jar. Then just run the mvn package command from the command line or using the Eclipse Maven plugin. This method requires some upfront work, but it buys you a consistent and easy jar export.

ABC123
  • 1,037
  • 2
  • 20
  • 44