Create .exe with Netbeans that allows installation directory selection - java

I have Netbeans set up on my project so that "Right click project -> Package As -> EXE Installer" will create an executable installer for the application.
The issue is that the installer sets up the application locally in
C:\%USERNAME%\AppData\Local\ApplicationName.
Is there any way to have the installer allow for selecting installation directory or, at the very least, install the application for all users?
usually we use C:\program files\...

I ended up no using the tools that Netbeans has built in since I find them very limiting.
Netbeans uses Inno Setup to create its executable files. Though it may exists, I could not find where to edit the script that Inno uses to create those executable files, so I went about it on my own.
I used this guide to combine all the dependencies into my application. If you have more than one, you add extra lines where the file says to do so.
I used Launch4j to package my .jar as a .exe.
I used Inno Setup to take that executable and make an installer with an icon, desktop icon and start menu icon support, and uninstall support. This is the script that I used (mostly generated with the gui) with removed personal info:
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId=generated guid
AppName=app name
AppVersion=1.0
;AppVerName=app version name
AppPublisher=company name
AppPublisherURL=company name
AppSupportURL=company site
AppUpdatesURL=company site
DefaultDirName={pf}\app name
DefaultGroupName=app name
AllowNoIcons=yes
OutputDir=output directory
OutputBaseFilename=setup
SetupIconFile=icon directory
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked
[Files]
Source: "exe location"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Icons]
Name: "{group}\application name"; Filename: "{app}\exe file"
Name: "{group}\{cm:UninstallProgram,application name}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\application name"; Filename: "{app}\application name.exe"; Tasks: desktopicon
[Run]
Filename: "{app}\application name.exe"; Description: "{cm:LaunchProgram,application name}"; Flags: nowait postinstall skipifsilent
I know this didn't really get a lot of traffic, but I hope it helps anyone that comes across it later.

Related

snapscraft snap.yaml for java apps using swing ui on ubuntu

I have a basic java app using java.awt Swing UI and I want to create a snap for it so when it's installed there is a launcher available and my UI Launches. I use gradle and the jar task to create a jar which works fine.
Naturally I have in a class that when called loads my app just fine:
package com.foo
class Bar() {
static void main(String... args) { launchUI() }
}
I created a snap folder at the root of the project and a snap.yaml where i followed the instructions on https://snapcraft.io/docs/java-applications so i have a snap yaml that produces a snap file which also installs fine:
name: deepthought
base: core18
version: '0.0.7'
summary: ""
icon: gui/foo.png
description: |
Computes the ultimate answer for life the universe and everything
grade: devel # must be 'stable' to release into candidate/stable channels
confinement: devmode # use 'strict' once you have the right plugs and slots
# This doesn't work
#apps:
# htmldoc:
# command: desktop-launch $SNAP/bin/foo.sh
## desktop: share/applications/htmldoc.desktop
# plugs: [home, network, x11]
parts:
foopart:
plugin: gradle
source: https://github.com/bsautner/foo.git
source-type: git
gradle-options: [] # suppress running of tests and run the war task
gradle-output-dir: build/libs
I've spent quite some time trying to figure out:
If i create a shell script to run a java -jar foo.jar command it ends up in the /snap directory but it's not on the users path so they can't get to it
I've tried creating launchers but always get an error that my launcher can't be found, if i put it in my root folder as /bin/launch.sh snap can't find it and if i put it in the snap/bin/ folder i also get errors to not put things in the snap folder
When I do install my snap, i don't see where it puts my jar i want to execute, so i can't write a script that does that
I'd really appreciate if anyone can share a working snap.yaml for a java program with a launcher and if there is any mention of a path to something that you note where those files are in relation to the path of the /snap/snap.yaml file
ok figured it out - the docs don't say this but the files are relative to the root of the project so even though the yaml says this is the launch
apps:
cmd3:
command: usr/bin/foo.sh
foo.sh should be in the root of the project and the orginize section here moves it to the bin dir
foo:
plugin: gradle
source-type: local
source: .
build-packages:
- openjdk-11-jdk
stage-packages:
- openjdk-11-jdk
- x11-utils
organize:
${SNAPCRAFT_PART_BUILD}/jg-snap: usr/bin/foo.sh
The jar is in the /snap/foo/current/usr/jar directory

How do I bundle a Custom C Shared Library with Java Application in Cloud Foundry?

I have previously been deploying a java application successfully in Cloud Foundry. However, now the developers have added a shared library compiled from C. I have added the .so to the .zip file (I'm using universal packager and deploying to Cloud Foundry by zip file) and ensured the .so is executable. However, when I deploy I get an error:
2016-12-23T14:39:01.013+00:00 [STG/0] [OUT] -----> Java Buildpack Version: eba4df6 | git://github.com/cloudfoundry/java-buildpack.git#eba4df6
2016-12-23T14:39:01.017+00:00 [STG/0] [ERR] [Buildpack] ERROR Compile failed with exception #<RuntimeError: No container can run this application. Please ensure that you’ve pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation.
2016-12-23T14:39:01.017+00:00 [STG/0] [ERR] No container can run this application. Please ensure that you’ve pushed a valid JVM artifact or artifacts using the -p command line argument or path manifest entry. Information about valid JVM artifacts can be found at https://github.com/cloudfoundry/java-buildpack#additional-documentation.
2016-12-23T14:39:01.022+00:00 [STG/0] [ERR] Failed to compile droplet
2016-12-23T14:39:01.024+00:00 [STG/0] [OUT] Exit status 223
So my understanding is that I need to created a Custom Buildpack from the Java Buildpack. However, I am getting stuck with the code at this point:
https://github.com/ONSdigital/java-buildpack/blob/master/bin/compile#L28
# Adding crf tagger library
status "Adding crf tagger support"
cp $bp_dir/parsers/src/main/resources/libbackend.so $build_dir/vendor/
# update the PATH
status "Building runtime environment"
mkdir -p $build_dir/.profile.d
echo "export PATH=\"$HOME/bin:\$HOME/vendor/:\$PATH\";" > $build_dir/.profile.d/crftagger.sh
echo "export LD_LIBRARY_PATH=\"\$HOME/vendor/\";" >> $build_dir/.profile.d/crftagger.sh
From what I can gather I only need to modify the compile stage. What do I need to do to copy over the .so and have the Buildpack run successfully.
Please take a look to this https://docs.cloudfoundry.org/devguide/deploy-apps/deploy-app.html#profile
Pre-Runtime Hooks that's you need. I can't give you more details because you haven't provided enough information (project structure, do you have .profile in you root and etc.).
If you need to add shared libs try to use attr_reader :additional_libraries https://github.com/cloudfoundry/java-buildpack/blob/master/docs/extending-droplet.md

Build .exe with javafx-gradle and InnoSetup and admin rights [duplicate]

This question already has answers here:
How to set 'Run as administrator' on a file using Inno Setup
(3 answers)
Closed 4 years ago.
I'm currently working on a project where I have to build a desktop application using JavaFX. I'm using the javafx-gradle-plugin (https://github.com/FibreFoX/javafx-gradle-plugin) for building and bundling the application.
Everything works fine, but after the installation the application doesn't request administrator privileges to run. If I start it with admin user everything works, but if you start it as a "normal" user the application doesn't work.
Is there a way for requesting admin privileges when starting the .exe?
thank you in advance for your help
I found the solution to my problem.
I added an entry in my .iss file for generating the InnoSetup installer like this:
[Registry]
Root: "HKLM"; Subkey: "SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers\"; ValueType: String; ValueName: "{app}\xxx.exe"; ValueData: "RUNASADMIN"; Flags: uninsdeletekeyifempty uninsdeletevalue; MinVersion: 0,6.1
Be aware that when you add this entry you have to add runascurrentuser to your Run configuration like this:
[Run]
Filename: "{app}\xxx.exe"; Parameters: "-Xappcds:generatecache"; Check: returnFalse()
Filename: "{app}\xxx.exe"; Description: "{cm:LaunchProgram,xxx}"; Flags: runascurrentuser nowait postinstall skipifsilent; Check: returnTrue()
Filename: "{app}\xxx.exe"; Parameters: "-install -svcName ""xxx"" -svcDesc ""xxx"" -mainExe ""xxx.exe"" "; Check: returnFalse()

JavaFX Self Installer With Inno Setup 5 - Where put the modify .iss file?

I am using Ant and Inno Setup to build a self deploying EXE for a JavaFX application.
For change the install folder I follow the answer of this topic
JavaFX Self Installer With Inno Setup 5 - Allow user to change install directory
But after make change I have now a problem i don't know where put exactly the new .iss file
I use eclipse, this is my project tree :
Quizz
|.settings
|bin
|build
|build
|deploy
|bundles
/* Exe here when I not change the iss file */
|dist
|project
|build.xml
|src
This is a part of my iss file, when i run him he don't find the icon and the exe file.
[Files]
Source: "Quizz\Quizz.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "Quizz\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
[Icons]
Name: "{group}\Quizz"; Filename: "{app}\Quizz.exe"; IconFilename: "{app}\Quizz.ico"; Check: returnTrue()
Name: "{commondesktop}\Quizz"; Filename: "{app}\Quizz.exe"; IconFilename: "{app}\Quizz.ico"; Check: returnFalse()
[Run]
Filename: "{app}\Quizz.exe"; Parameters: "-Xappcds:generatecache"; Check: returnFalse()
Filename: "{app}\Quizz.exe"; Description: "{cm:LaunchProgram,Quizz}"; Flags: nowait postinstall skipifsilent; Check: returnTrue()
Filename: "{app}\Quizz.exe"; Parameters: "-install -svcName ""Quizz"" -svcDesc ""Quizz"" -mainExe ""Quizz.exe"" "; Check: returnFalse()
[UninstallRun]
Filename: "{app}\Quizz.exe "; Parameters: "-uninstall -svcName Quizz -stopOnUninstall"; Check: returnFalse()
So the question is where I should put the iss file ?
If someone can help me he will be very very nice.
I didn't find the answer but I found a workaround :
There are two .exe files, the application .exe that runs the jar, and the self-deploying .exe generated by Inno-Setup.
I used the Ant script to generate the application .exe, by changing nativeBundles to "all" like so:
<fx:deploy
...
...
nativeBundles ="all"/>
Once run, the Ant script creates a .jar, .jnlp, the jre and the two .exe.
The application .exe, which is needed by Inno Setup, is actually generated then destroyed silently when you choose nativeBundles="exe".
So with nativeBundle="all" I was able to customize my Inno Setup script, so it installs the exe and the jre in the right folder.
The answer is: your modified .iss file should be placed in SAME_DIR_AS_YOUR_ANT_BUILD_FILE\package\windows\ (create those folders if they don't exist). More info can be found in this Oracle article, section 6.3.3.

Executing Java program (NCBO Extraction Tool) from Windows command prompt not working ... User Guide uses Linux syntax

I'm trying to run a Java command line program from the Windows command prompt to extract and generate an ontology file from the BioPortal (http://bioportal.bioontology.org). It appears that it can't find the class, but perhaps my CLASSPATH parameter syntax is incorrect. Reference for setup (NCBO user guide and NCBO extraction tool zip file) can be found at the bottom of my question. The instructions are based on Linux syntax, but I'm running this in Windows.
Linux command (from user guide):
java -classpath endorsed_lib/*:genlib/i2b2Common-core.jar:lib/commons/*:lib/log4j/*:lib/jdbc/*:lib/spring/*:* edu.harvard.i2b2.ncbo.extraction.NCBOOntologyExtractAll -ont {5 digit ontology id} -apikey {API key from http://bioportal.bioontology.org/account} -outputFileName {output file path}
The Linux -classpath parameter includes these:
endorsed_lib/*
genlib/i2b2Common-core.jar or genlib/* (only 1 jar file)
lib/commons/*
lib/log4j/*
lib/jdbc/*
lib/spring/*
*
Windows command (that doesn't work):
java -cp ".\endorsed_lib;.\genlib;.\lib\commons;.\lib\jdbc;.\lib\log4j;.\lib\spring;." edu.harvard.i2b2.ncbo.extraction.NCBOOntologyExtractAll -ont 47178 -apikey 68775b88-c12f-472c-9192-71f9b282309c -outputFileName 47178_stagingFile.txt
Error from Windows command prompt:
Error: Could not find or load main class edu.harvard.i2b2.ncbo.extraction.NCBOOntologyExtractAll
The Windows -cp (CLASSPATH) parameter includes these paths:
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib\;
\NCBOExtractionTools_1.1\Release_1_1\genlib\;
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\;
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\;
\NCBOExtractionTools_1.1\Release_1_1\lib\log4j\;
\NCBOExtractionTools_1.1\Release_1_1\lib\spring\;
\NCBOExtractionTools_1.1\Release_1_1\;
=================
Guide:
https://community.i2b2.org/wiki/download/attachments/5670011/NCBO_Extraction_Users_Guide_1-1.pdf?version=2&modificationDate=1344357357000
Instructions start on page 8 of 16. I'm on page 9.
In the user guide, it references an NCBO utility. That can be downloaded here:
https://www.i2b2.org/software/download.html?d=310
click the blue hyperlink labeled "file download" or click link below (link as of 1/4/2013) > then click "I ACCEPT" > save file (NCBOExtractionTools_1.1.zip) to your local machine > extract zip file
Here is a list of the files extracted from the i2b2 NCBO utility so you can see what jar files we have available:
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib
\NCBOExtractionTools_1.1\Release_1_1\ExtractionApplicationContext.xml
\NCBOExtractionTools_1.1\Release_1_1\FileList.txt
\NCBOExtractionTools_1.1\Release_1_1\genlib
\NCBOExtractionTools_1.1\Release_1_1\hierarchy.log
\NCBOExtractionTools_1.1\Release_1_1\i2b2_license_2.1-1159.txt
\NCBOExtractionTools_1.1\Release_1_1\lib
\NCBOExtractionTools_1.1\Release_1_1\log4j.properties
\NCBOExtractionTools_1.1\Release_1_1\NCBOExtraction_1.1.jar
\NCBOExtractionTools_1.1\Release_1_1\STAGING_FILES
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib\jaxb-api.jar
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib\jaxb-LICENSE.txt
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib\stax-api-1.0.1.jar
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib\stax-api-LICENSE.txt
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib\wstx-asl-3.0.1.jar
\NCBOExtractionTools_1.1\Release_1_1\endorsed_lib\wstx-LICENSE.txt
\NCBOExtractionTools_1.1\Release_1_1\genlib\i2b2Common-core.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\commons
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc
\NCBOExtractionTools_1.1\Release_1_1\lib\log4j
\NCBOExtractionTools_1.1\Release_1_1\lib\spring
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\apache-2.0license.txt
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\commons-codec-1.3.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\commons-collections-2.1.1.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\commons-dbcp-1.2.2.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\commons-exec-1.0.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\commons-httpclient-3.0.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\commons-logging-1.0.4.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\commons\commons-pool-1.3.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\ojdbc14.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\sqlserver2005
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\sqlserver_jTDS
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\sqlserver2005\sqljdbc.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\sqlserver2005\sqlserver_licence.rtf
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\sqlserver_jTDS\jtds-1.2.2.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\jdbc\sqlserver_jTDS\LICENSE
\NCBOExtractionTools_1.1\Release_1_1\lib\log4j\log4j-1.2.8.jar
\NCBOExtractionTools_1.1\Release_1_1\lib\log4j\log4j-LICENSE.txt
\NCBOExtractionTools_1.1\Release_1_1\lib\spring\apachelicence-2.0.txt
\NCBOExtractionTools_1.1\Release_1_1\lib\spring\spring-2.0.jar
This worked per #Brian's comment:
java -cp ".\endorsed_lib\*;.\genlib\*;.\lib\commons\*;.\lib\jdbc\*;.\lib\log4j\*;.\lib\spring\*;.\*" edu.harvard.i2b2.ncbo.extraction.NCBOOntologyExtractAll -ont 47178 -apikey {key} -outputFileName 47178_stagingFile.txt

Categories