-2

Possible Duplicate:
How to make an executable jar file?

I want to distrubute my Java program to another person who wants to check out the software, but I don't want to reveal the code, until later if he requests it. How can I send my Java code + few xml files in a folder?

I've been thinking if jar is used for this purpose of distributing progrms. If so, Can it be used in my case? What are the other easy options?

Caveats: I don't have much time to spend. So i need something that can be done fast and is easy and no learning required. Also any links for steps-wise tutorial will be helpful

UPDATE: While making executable jar in Eclipse, is saying: Compile error.

Community
  • 1
  • 1
Jaison Varghese
  • 1,302
  • 1
  • 13
  • 24
  • 12
    "easy and no learning required" - lol! – Mitch Wheat Apr 22 '12 at 09:27
  • 1
    "I don't want to reveal the code, until later if he requests it". This is essentially impossible. Java is fairly easily decompiled. You'll need either some degree of trust in your business relationship or demonstrate the software in person on a laptop you control. The moment you send a file, your source code (or a close approximation thereof) is revealed if the other side wants it badly enough. – Barend Apr 22 '12 at 11:04
  • Make your code obfscated – cl-r Apr 22 '12 at 15:02

2 Answers2

1

No problem. You can make a JAR file with your IDE (e.g. Eclipse). Just click on export. You can include the source files, but you don't have to. You can also include your resources like a XML file.

You can also zip the compiled class files (e.g. your bin-folder in your IDE). But the JAR would be the better solution.

But test the JAR file before you send it. If it is your first time, there will properly be some problems like not founded resources or a missing main-class declaration in the manifest file. But if you using an IDE it should work in a minute.

Thomas Uhrig
  • 30,811
  • 12
  • 60
  • 80
0

To make an executable jar file use command

jar -cvfe

To test if its working, just double click the jar. Be sure to include any libraries in the manifest.mf file.

Or you could just use your IDE to do the job for you.

sachinrahulsourav
  • 742
  • 1
  • 7
  • 16