0

I have a Java project and I successfully executed that in Eclipse. Now how I do that to make an installable file.

I'm using Linux mint so tell based on this OS.

I'm trying in DEBIAN but I didn't get success in that.

And finally I need to know what I have to write/code in preinst, postinst, prerm, and postrm files.

durron597
  • 31,968
  • 17
  • 99
  • 158

3 Answers3

1

Debian File Creation

Step 1: Create a folder of with your desied project name. [eg. projectname]

Step 2: Create an empty folders as follows.

  1. DEBIAN [must be caps]
  2. usr

Step 3: Within DEBIAN folder create a file as 'control' without any extention and put the following data in to that.

Package: projectname
Version: 2.6-r1473-1
Section: editors
Priority: optional
Architecture: all
Depends: sun-java5-jre | sun-java6-jre | openjdk-6-jre | openjdk-7-jre
Conflicts: projectname-praha
Replaces: projectname-praha
Installed-Size: 15684
Maintainer: projectname Developers <contact@projectname.biz>
Homepage: http://projectname.biz/
Description: Free cross-platform project scheduling and management tool. Gantt chart, resource load chart, MS Project import/export.
 projectname is a free and easy to use Gantt chart based project scheduling and management tool.
 The full installation includes:
 .
 * Task hierarchy and dependencies
 * Gantt chart
 * Resource load chart
 * Generation of PERT chart
 * WebDAV based groupwork
 * Export to PDF and HTML
 * Microsoft Project import and export

Finally save and exit.

Step 4: Within DEBIAN folder create a file as 'postinst' without any extention and put this in that

#!/bin/sh 
set-e

if [ "$1" = "configure" ]; then 
    if [ -e /usr/bin/projectname ]; then rm -f usr/bin/projectname; fi 

    ln -s /usr/bin/projectname/projectname /usr/bin/projectname 

    if [ -x "$(which update-menus 2>/dev/null)" ]; then update-menus; fi 
    if [ -x "$(which update-mime 2>/dev/null)" ]; then update-mime; fi 
fi

Here, in 6th line "/usr/bin/projectname" are user defined, you can defined as your own that where you need to install your project.

Step 5: Within DEBIAN folder create a file as 'postrm' without any extention and put this in that

#!/bin/sh
set-e
    if [ -e /usr/bin/projectname ]; then rm -f usr/bin/projectname; fi

    if [ -x "$(which update-mime >/dev/null 2>&1)" ]; then update-mime; fi

    if [ -x "$(which update-menus 2>/dev/null)" ]; then update-menus; fi

fi

Step 6: Within 'usr' folder create a folder as 'lib' and 'share' folders

  • Within 'lib' folder create 'mime' folder.
  • Within 'mime' folder create 'packages' folder.
  • Within 'packages' create a document as projectname with out any extention and put the following datas in it.

    application/projectname+xml; projectname '%s'; description="projectname file"; test=test -n "$DISPLAY"; nametemplate=%s.gan 
    

Step 7: Now come back to 'share' folder create five folders within the name of applications, doc, projectname, mime, pixmaps. Now

  • Within 'applications' folder put 'projectname.desktop' file.
  • Within 'doc' folder create 'projectname' folder and put the AUTHORS, README, LICENSE file from your project.

Now come back to 'share' folder and within 'projectname' folder put [ plugins folder, eclipsito.jar, projectname, HouseBuildingSample.gan (Here, projectname is runnable file.)] files from your project. These plugins folder, eclipsito.jar, projectname, HouseBuildingSample.gan things were created after you finish the execution of your project.

Now come back to 'share' folder and within 'mime' folder, create folder as 'packages' and within this folder put 'projectname.xml' file from your project. Now come back to 'share' folder and within 'pixmaps' folder put 'projectname.png' file from your project. Instead of extention .png may use .jpeg or jpg.

Step 8: Now open the Terninal and open the folder/path that where the project is located (e.g. cd Desktop):

write sudo dpkg -b <projectname>

The Debian file will be created. You can use that file to install that.

Errors While doing Debian packages:

May have chance to get like this errors that

control directory has bad permission 555 (must be>=0755 <=0775)

To solve this type of errors give this command

chmod 0755 <path of the project>

Eg: chmod 0755 /home/vrmg15/Desktop/projectname/DEBIAN

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
  • I have worked out this only in linux mint I dont aware about other OS... –  Sep 28 '13 at 11:09
0

If you really want an installer, I would recommend writing it yourself, but I think, what you mean is exporting it as an executable file.

For the second option do the following in eclipse: File->Export...->Java/Runnable Jar File

Your launch configuration will have the name of the class which contains your main method. As filename you should use yourapplication.jar.

After clicking finish you can execute that file by double clicking it, or using java -jar yourapplication.jar on the command line.

Edit: You will need your exported jar file in order to create a debian package. I don't have any experiences with debian packages, but I am shure this must be done outside of eclipse.

If you want to launch your program with a single terminal command, you can place the following script inside /usr/bin

#!/bin/sh
java -jar /path/to/your/jarfile

and make it executable (chmod +x /usr/bin/yourapp)

mafrasi2
  • 312
  • 1
  • 3
  • 14
  • Yes i did this but there is Finish button didn't highlight...I can't select the Finish button, after selecting the path... –  Sep 26 '13 at 11:57
  • Did you select your launch configuration and do you have write permissions to the destination? Is there a explanation in the top line? Maybe you just checked "Save as ANT script" – mafrasi2 Sep 26 '13 at 12:12
  • yes I have select that Save as Ant Script and I given the path, also I have given path to Export destination –  Sep 26 '13 at 12:30
  • just unselect save as ant script – mafrasi2 Sep 26 '13 at 12:34
  • S i unselect that but not works ya... –  Sep 26 '13 at 13:31
  • that's weird, no idea why that doesn't work – mafrasi2 Sep 26 '13 at 13:50
-1

you must make a jar file with few java files