I'm developing java applications for Windows and I want to automate the installer generation.
Is there any cmd line utility or API to do that?
EDIT
The best alternative I've found is http://izpack.org , which builds installers from XML files. It seems that they have enough documentation to understand how to make a "IzPack XML File generator" or even build them by hand (for small projects) and automatize the installer generation. Any new suggestion will be welcomed.
See if this is useful : http://antigen.sourceforge.net/
Related
since .jar is not anymore the best format to use to distribute our JavaFX project, I'm willing to use the tool JPackage for that instead, but after reading this post : https://stackoverflow.com/a/68823040/4262407, I ended up having multiple questions, but first of all, I just wanna make sure I ve well understood the process that I should follow :
the process :
1-create a modular project
2-package the project in a .jar format
3-use the tool Jlink to create a customized run-time image (to reduce the size of the output)
4-use the tool jpackage (it takes 2 and 3 as inputs)
I'm also wondering if I can rely on Intellij artifacts to create the .jar file (the 2 step) is it better to use a specific plugin ?
The last thing that is not clear is do we need to include the dependencies in the .jar file ? since I believe they will be included in the customized run time, won't they?
If you take a look here, there is an explanation on how to create JavaFX projects starting from a template that includes Maven plugins to easily pack the application using jlink.
Doing it like this will allow you to completely rely on IntelliJ, making things much easier.
Once you have your runtime image, you can pack it with jpackage. There was already a discussion about this topic here.
And here is a fast link to the article mentioned there. The article there shows it using Gradle, but you can do the same with Maven, just use the appropriate plugin (jpackage-maven-plugin, as stated in another answer here).
Also, from what I can read in your comments, it seems that you have both modular and non-modular dependencies. In that case, you can use jdeps to achieve what you need. There is a nice article here about having mixed dependencies, that specifically uses JavaFX as an example of modular library within a non-modular application.
Just have look here https://github.com/dlemmermann/JPackageScriptFX for a tutorial with a working example. Its especially useful for non-modular projects.
I used the jpackage maven plug-in to build the native executable(https://search.maven.org/artifact/org.panteleyev/jpackage-maven-plugin).
You will first have to use maven-javafx-plugin to create a jlink runtime image(https://github.com/openjfx/javafx-maven-plugin).
You will then use that runtime image within jpackage plugin(... ).should create an executable successfully then.
The jpackage tool does not require a modular project. Though if your project is not modular then your project will be mixed due to JavaFX being modular. In that case, you'll add the JavaFX modules to the custom run-time image while telling jpackage to treat your code as non-modular (i.e. it will configure the executable to place your code on the class-path).
You can also combine steps 3 and 4 into a single step. The jpackage tool can generate the custom run-time image. It will use jlink "behind the scenes".
As for what format your code needs to be in, packaging it in a JAR file will be, in my opinion, the most straightforward. But I'm not sure that's strictly required.
Any dependencies of your application will of course need to be included with the final application. If those dependencies are modular then you can have them included via the custom run-time image. But if you want them on the class-path then you can include them the same way as your code (i.e. --input).
Note the jpackage tool has a user guide: https://docs.oracle.com/en/java/javase/16/jpackage/packaging-overview.html
Our Java Swing application is running on Windows and wrapped in an exe file using Launch4J.
We would like to customize our application process name and description (in Windows' task manager) as it is currently "javaw.exe" and "Java Platform SE binary" (which is confusing for our customers).
While older versions of Launch4J enabled to change this using <customProcName>, this option is now defunct as it is not working anymore as of Win7.
Is there any other (simple) workaround to customize our application process name and description?
For instance, changing javaw.exe executable filename seems like an approach (as we embed it in the wrapped exe file) but how then indicate to launch4j that the jvm file name changed?
Another option could be to create a launcher exe file: maybe an overkill?
Any ideas / hints are more than welcome; thanks!
If you're looking to roll your own solution, you're going to want to look at JNI and the Invocation API in particular JNI_CreateJavaVM() which is used to create a VM, find the main method GetStaticMethodID() and invoke it with CallStaticVoidMethod.
This is what the java.exe, javaw.exe and a variety of other native launchers do internally. Some examples include:
OpenJDK java.c
IntelliJ WinLauncher.cpp
WinRun4J VM.cpp
If you want don't want to integrate a native build system with your java build system, an approach is to build a static launcher.exe in advance, and treat it as a static binary blob. Then during your java build, modify the binary blob using java, to update the VERSIONINFO, icon and splash screen. An example of this approach can be seen in IntelliJ LauncherGeneratorMain.java
If you can afford it, JSmooth seems to do what you need. It's last released in 2007 though. A note about its license taken from the app itself:
The executable generated (the launchers created by JSmooth) are under the LGPL with a "runtime exception" similar to the gcc licence exception: It is not required that you distribute the source code with it, nor that you publish a notice mentionning jsmooth.
When using JSmooth, there is a section labeled "Skeleton" that allows you to select some pre-defined parameters. One of them is a "Windowed Wrapper" that is fit for GUI applications described as follows:
This skeleton wraps GUI applications.
No console I/O is displayed
If no Java VM is found, it is able to display a configurable URL (typically to a java download page).
Arguments can be passed to the application (either use the JSmooth default argument mechanism, or create a shortcut with arguments).
The important thing in this skeleton is to check the option "Launch java app in the exe process" which results in running the JVM in the same process as the wrapper exe. This means only the exe is shown in the Windows Task Manager, as opposed to both the exe and the java process.
The alternative is to write your own wrapper. See this Oracle guide for how to invoke the JVM from a native application.
I did similar things with WinRun4J, as far as I remember it can be used commercially because it is CPL licensed. Checked this today: settings the process name still works (initially did this on XP) with Windows 7.
According to the website you simply create a ini file which tells WinRun4J what to run:
main.class=org.something.MyMainClass
classpath.1=*.jar
(there are many more parameters, you can set where the JRE can be found and more)
In a second step you copy the winrun4j.exe to something that fits your application:
copy winrun4j.exe yourapplication.exe
(There is a version for Windows x64 too)
Then you have RCEDIT (comes with WinRun4j) add the ini to the exe:
rcedit /N yourapplication.exe yourapplication.ini
This seems pretty old, and not really worth the effort, but it may also be what you are looking for: Java exe Maker.
I am trying to begin writing a Java program in Xcode 4.4 but, At the moment, I am stuck with the file extension .cpp, which I believe is for C++. Can some please tell me how to set up a .java file (or project, or whatever the term is)...? I am extremely new to programming, and to Xcode, so please keep all instructions /very/ simple.
I have created some Xcode Templates for Xcode 4 here
http://www.2shared.com/file/hExLjJ1X/Java_Xcode4_template2.html
To install the template in Mac, use Terminal command
mkdir -p ~/Library/Developer/Xcode/Templates/
unzip ~/Downloads/Java_Xcode4_template2.zip -d ~/Library/Developer/Xcode/Templates/
You can use command-B to build. To Run, you should use "Edit Scheme..." and change the Executable for the "Run" Scheme
If you're new to programming you might want to try this in a different way.
Better IDEs for Java are Netbeans and Eclipse. I've used Netbeans for Java and PHP as well. It behaves as you could expect from a modern IDE with a lot of possibilities for customizing it to your needs/preferences.
Xcode is great and has many useful tools but it's focused on objective-c and iOS environment.
Good luck!
I am using XCode currently.
Open a new project.
Click External Build System.
Name your file, using the extension .java.
Write $(TARGETNAME).java next to $(ACTION).
Open a new file (empty style).
Start writing your program.
XCode is not the best place for Java, but I use it since it is a developer tool for Apple and it has great syntax coloring and auto-indentation, etc.
TextEdit is another app (probably already there if you use Apple Mac), but no syntax coloring and fancy features. It is simpler to use, and always use Terminal (try to avoid using the XCode Build - the errors are hard to decipher and the process is complicated, also if you have any questions, few can answer it because most do not use XCode).
Good luck!
In Visual Studio land, I used to be able to define a structure in an XSD file and add a special attribute to it which would cause it to be dynamically compiled and available to use with intellisense in the other C# files in the application. I am not sure exactly what the term for this is, perhaps "dynamic code generation."
I am trying to accomplish the same in Java using Eclipse IDE. Basically what I am looking for is a tool that will allow me to specify some template and generate Java code from it in a "hot folder" that will allow me code complete in the other static Java files.
Does anyone know of a solution for this? I know it is possible in Visual Studio, but I can't seem to find anything for Eclipse.
Ok, here is exactly what I want to do.
Step 1. I create a folder called templates
Step 2. I create a file called HelloWord.ibes
Step 3. Code it automatically generated in my src folder HelloWorld.java
I want to be able to do this in eclipse easily.
You may create an ant build file that does the source generation for you. Then you are free to use any code generator you like. Ant support is part of the eclipse IDE. If you prefer maven, there's a nice eclipse pluging available (that's what I actually use for source code generation based on jaxb, javacc and xdoclet...).
Technically spoken, you just add another eclipse builder which is invoked anytime eclipse detects a change in your code base.
If you already have a code generator in mind, just 'ask' the internet if there's a plugin available.
Edit
On how to install a builder: This is done automatically. For maven, you just install the maven plugin (m2eclipse) and enable maven dependencies for a project. Then if you look at the projects properties pages (Builder section), you find a second entry in the list of builders.
It's similiar with ant, even easier, because ant is already integrated. "enable" ant for a project and the builder is added to the list of builders for the project. You can deselect it at any time if it kills performance or switch of automatic building (I don't know by heart how to enable ant builds for a project, but I remember that the eclipse help had sufficiant informations).
All about ant can be found here: Apache Ant
Creating a new builder is difficult, as it has to be coded in java and added to eclipse as a plugin. I bet you don't want to follow that track ;)
I'm not sure whether you have seen the code template option?
Preferences.Java, Code Style then Code Templates
How
to add code templates
Useful
code templates
I am looking for a utility that will suck in an ant build file and present a graphical display of the targets and properties available to that target. Please don't respond with 'VisualAnt' I own it and it sucks.
I use yWorks Ant Explorer. It runs as a stand alone app. It's pretty good. Apparently there is an Eclipse plugin as well but I haven't been able to locate that.
It's free. Not sure if yWorks still develops it. You can download the jar here and here. After download, just create a bat file with this command:
java -jar antexplorer.jar
Look at Elements of Ant Style wiki page. They have a link there for a XSLT style sheet that makes a build file browsable. Here is a link for it. The wiki page also shows how to use it.
Linguine Maps is maybe an option.
See Create entity-relation diagram text
Bye.
If you are an Eclipse user, take a look at Ant Visualization Plugin for Eclipse