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.
Related
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
I want to use the Light Weight Java Gaming Library(LWJGL) to my Netbeans so I can use it in my Java application. The only videos that I can find show the zip file that they downloaded with separate src and doc folders inside of it. The zip file that I download has everything in one directory. I went to lwjgl.org/download and clicked on Stable and then Generate Bundle. What am I missing?
I had the same problem recently.
So, to begin you want to go to Tools in the context menu and select Libraries (as shown). Next you can add a new library and name it e.g. LWJGL-3.1.1 confirm with ok. You can find 3 tabs in the current window Classpath, Sources and Javadoc. There you add your jar files accordingly (in the downloaded .zip file you find .jar files with different names like lwjgl-{whatever}-sources.jar or lwjgl-{whatever}-javadocs.jar) make sure you put them in the right place. You have to repeat this process for all of the jar files you want. The javadoc files are not required but recommended. Make sure you also collect all the native .dll files and merge them in a folder called \natives. You find them in these jar files that are called like: lwjgl-{whatever}-{your-OS}.jar.
Once you have finished the setup for your library right click on your current project and choose Add Library.... In the window that pops up you scroll down until you find your library that you have just created and you are almost done now.
Last but not least go to the project settings. Select Run and make sure that you set the classpath in VM options to something like in the image: -Djava.library.path="C:\java_workspace\LWJGL Library 3.1\natives. Now this classpath tells netbeans where your native files are located. Your \natives folder that you should have created in the beginning is where this path should lead to. That's it. This is all you have to do for a setup without the use of maven, gradle, ...
You can test if it is working with the code provided by LWJGL HelloWorld example.
I hope this solved your problem.
Best regards.
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.
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.
I have a java desktop application for which I am trying to create a Mac application package. The application is composed of two runnable jar files and several folders of text and images. The first jar acts as an updater and launcher for the second jar which is the bulk of the application. The application uses a variety of data files and images that are referenced in the application by relative path name (e.g. ./images/bits/xyz.jpg).
On Macs, however, I am having trouble getting the relative pathnames to work after creating a Application Bundle with Jar Bundler. I have no personal experience with Macs and need help understanding the standard way to laying out an application on them. I have noticed that other applications that I have installed come as a disk image file that opens with instructions to drag the app into the applications folder. I am trying to create a similar install package. Thank you in advance for your advice.
Drag and drop instruction in a disk image is a complete red herring. Once the app bundle is correctly made, it does not matter whether it's in the disk image or it's just zipped.
Note that on Macs, executables (whether native Cocoa or Java) don't have its current directory set to the path of the executable. So, you first need to get the current absolute path of the jar file, say. For that, there are already Q&As on Stack Overflow. See e.g. here.
You might need a Mac in order to create a proper Java Bundle and a DMG file.
Here is a simple example:
http://www.centerkey.com/mac/java/
And here is a tutorial on how to make use of Mac-specific Swing features:
http://java.sun.com/developer/technicalArticles/JavaLP/JavaToMac3/
As a developer with Pyxis Software, I would like to add that we have developed an application that solves this issue. The application named Pyxis Bundler will automatically bundle your jar file and optional libraries into a standard Mac application.
You can optionally embed the JRE from your JAVAHOME directory or select a specific JRE. While this will clearly enlarge the size of your application, the user does not need to have JAVA pre-installed on their machine to run your application.
There is also an option to create a modern Apple Icon image (multi size ICNS file).
We designed this as a replacement for the Jar Bundler application that used to be shipped with Xcode up to a number of years ago.
Pyxis Bundler saves each unique application settings to a preferences file, so if or when you update your Mac application, you only need to select the application name from a drop-down list to load all previously used data for that application. Then simply increment your version number and click the Create button.
I should add that with Pyxis Bundler you must use proper package names.
More information is available here:
https://explorepyxis.com/shop
http://www.pyxis.ie/explore/index.php/software/pyxis-jar-bundler
You can check-out how to name packages here: https://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html