How do I package a Java program for Ubuntu? - java

I have an application that currently a user downloads and runs an install script. I want to be able to take the JAR file and such that is generated by NetBeans and make it into a package that a user can download through a package manager. It needs to have menus implemented as well (the entries in the Debian menu that the user can click on).
Currently I am following through this tutorial: http://packaging.ubuntu.com/html/packaging-new-software.html
However, I am worried that I am going down some kind of rabbit hole in the wrong direction. Surely this must be something that is common?
What is the standard procedure for getting your JAR file to other people through packages?

I needed to:
Install dpkg.
Create a directory structure similar to how I would like it unpacked.
Create a shell script that would copy it there.
Run dpkg.

Related

How to assure windows that my app is safe to run?

For my college project, I created a MapGenerator to create maps for the project. It is a group project, so I converted my .java files to .exe using Launch4J.
I then shared it to my friends using Google Drive. But then, while downloading, my friends said that Google said that the download is potentially dangerous. They just selected "Keep" and continued the download. The problem came when Windows doesn't let them to run that app at all. We know it's a safe application and does nothing wrong other than creating .csv files.
So, is there any way to assure Windows that this is a safe application and allow it to run the application?
PS: I use IntelliJ without gradle or maven, just IntelliJ (if this is a necessary info)
You can select the exe you want to run --> Click properties --> Under the general tab beside the security option --> check the unblock. Then it should definitely run
To have your exe like other software , you have to get your exe signed but I don't know how to do it. The solution I gave is a duct tape glue solution and I thought it would help.
You can check this link for more info:-
Signing a Windows EXE file

Java application requires Admin Access to run when placed in Program Files

I am working on a Java (JavaFX) desktop app. I am converting it to exe with launch4j tool and then later creating a setup package using Inno Setup Compiler (default installation path set to C:\Program Files (x86))
The application itself don't need any admin privileges and runs fine when I copy the exe on desktop or run it on drives other than C. (Also works fine if I run it in local appdata folder)
But I need to place it in Program Files (x86) directory.
The app doesn't open if I install it in that directory so I had to create a manifest file for launch4j so that it asks admin access each time it opens. It works fine that way but admin access is asked everytime in this case.
I need to make this application run without asking admin access each time.
If there is any solution, please guide me through it.
Any help will be appreciated.
Ok so I kind of figured that out. I guess the jar was having trouble reading from system directories and I had to do some read/write operations on a config file. So I changed the config path to:
String path = Controller.class.getProtectionDomain().getCodeSource().getLocation().getPath() + "\\Data\\";
Now it creates a folder named "Data" inside jar file and read/write from there. I don't know if this is a bad practice or not but it seems to work pretty good for me.
Thanks a lot to #user31601 who gave me some hint that helped me figure this solution out.

How to export my program into a runnable desktop file?

first time posting here, java beginner.
I made a basic calculator that receives user input. Is there a way to export my program to make a runnable desktop file?
My IDE is IntelliJ.
Thanks in advance!!
Assuming you are building a JavaFX app:
The easiest way to deploy your app is to go to File>Project Structure>Artifacts.
Add your available elements (if you have any extra images etc) into your output root, and click on your jar file. At the bottom of the window you'll see options to either create a manifest file or modify an existing one.
The manifest file describes the first class to load in your program (the starting point) as well as the locations of any third party libraries you may have included in your program.
You will also have a JavaFX tab that you can use to set some initial parameters for your app, such as the title, version, and whether you want to deploy any native bundles (eg: .exe for Windows, .deb for Ubuntu etc)
Once you have configured the important parameters you want, save your settings (or just select any field and click enter) and go to Build>Build Artifacts>Action: Build
IntelliJ should generate an executable .jar file and any native bundles you selected. The native bundles can just be double clicked, and the jar file can be run using a JRE.
On blog.jetbrains.com they show the steps with some screenshots.
Note that this entire process is called deploying your app and there are a variety of tools and methods to do it. I just described what I believe is the simplest way.

How make an installer for a java application?

I made a netbeans java application (javax.swing), connecting to the mysql database. The connection is made through localhost. Now I would like to create an installer for this application. In order to install my project on other computers.
What do I need to do in order to create an installer?
I'll have to make some kind of change in the database, or connection?
Do you know any simple program? I've been researching this: http://www.clickteam.com/install-creator-2
Thank you all for your help.
If someone did not understand my question, I try to explain better.
I apologize for the inconvenience.
Greetings.
right click in you project;
click on "Clean and Build";
After that go to the netbeans project folder;
It creats a new folder called: "Dist"
In this folder will have a file ProjectName.Jar (Does an executable of your
application);
After that run the program you mentioned, this will transform executable "ProjectName.Jar" into an installer.
For that try this tutorials:
http://www.youtube.com/watch?v=G8ccin6w4JM&list=PLB04B4E5D9B58C13D&index=114
In this videos you will find a very simple way to create an executable and an installer of your application.

Eclipse create java executable with external libraries

I've seen this topic in this forum but it I need a more basic explanation on how to do this.
I've done a program in Java with some external libraries (LWJGL and Slick).
So this is what I've done and my program won't start anyway, tell me where I've done wrong.
I have Eclipse 3.7.1
My project is opened in Eclipse and runs well in Eclipse
I click File -> Export
I select Java -> Runnable JAR file
Here I don't know what to choose in Launch configuration, when I click the dropdown I get the option to choose my main class so I do that.
I select an export destination
I select the option "Package required libraries into generated JAR" under Library Handling
I don't know what ANT script is so I don't use that
I click Finish
I copy my images-folder to the same location as the generate JAR-file
I try to start the JAR-file, something loads in the background but nothing happens, no window shows up, nothing.
I check the Task manager in windows and sees that a javaw.exe is running
What did I miss?
My program uses images for graphics like this:
image = new Image("images/filname.png");
I wonder if I need to change the paths before exporting or the method to load these?
Thanks!
If you want to get things from inside a jar file you need to have them in your classpath and access them as resources.
The constructor you use, refers to a physical file which cannot peek inside a jar-file.
(EDIT) Also note that you have no guarantee where the current working directory is. Hence any relative references may break, as you see.
Read this to learn how to use JarSplice to export your Eclipse project to a runnable jar-file. Regarding images, you can put them in the same directory as a class file (in the jar) and then writeSampleClass.class.getResourceAsStream("image.png")to retrieve an InputStream of the image. Then you can load it however you like.
I had the same problem and I was able to fix it. All I did was copy the data folder (which contains my resources) into the *.jar file. You can do this for example with WinRAR.

Categories

Resources