Skip to content

Commit

Permalink
Merge pull request #16 from michab66/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
michab66 authored Mar 14, 2020
2 parents 82ac327 + 4ce56b5 commit a61415e
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Get the latest version of the jlgen executable from the project's [release page]
`jlgen.exe` is a command line application that supports different commands. The command *`MakeLauncher`* represents the central functionality of the software. It generates a native Windows launcher for a JLink-generated Java application image.

The required parameters are:
* The name of the target file, e.g. 'Farboo.exe'.
* The name of the target file, e.g. 'Farboo.exe'. If the .exe extension is not specified then it is added.
* The name of an icon file that is used to generate the required icon resources in the executable, e.g. 'farboo.png'. Note that a *.png* file is required, no hassle with generating an .ico file. It is recommended to offer a square, high resolution image, though all sizes and resolutions will do. This image gets scaled and resized for the resolutions 16, 32, 64, 128, 256 pixels.
* The name of the target module. That is, the name of the module that holds the main Java application. For example `app.mmt`.
* Finally, the name of the Java class representing the entry point to the application. This class has to offer the Java-application's `public static void main( String[] argv )` operation. An example is `de/michab/app/mmt/Mmt`, note that you have to use `/` in this name instead of the `.`s used for example in `package` references.
* Finally, the name of the Java class representing the entry point to the application. This class has to offer the Java-application's `public static void main( String[] argv )` operation. An example is `de.michab.app.mmt.Mmt`.

A complete sample call may look like

`jlgen MakeLauncher C:\cygwin64\tmp\Farboo.exe ..\mmt-icon-1024.png app.mmt de/michab/app/mmt/Mmt`.
`jlgen MakeLauncher C:\cygwin64\tmp\Farboo.exe ..\mmt-icon-1024.png app.mmt de.michab.app.mmt.Mmt`.

## I have the launcher executable, what now?
Note that the generated launcher--in our example 'Farboo.exe'--has to be placed in the existing jlink image directory hierarchy at the same position where the file `jvm.dll` is located. This is currently `{jlink-app-root}/bin/server` but this may change in coming versions of the Jdk. (It is a deliberate decision not to look-up the jvm.dll dynamically to prevent to start the target application using a wrong Jdk/Jre that non-deterministically happened to be found.)
Expand Down
27 changes: 23 additions & 4 deletions jlgen/jlgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,26 +112,45 @@ namespace jlgen
return EXIT_SUCCESS;
}

/**
* Default extension of the generated executable.
*/
const auto exe_k = ".exe";

/*
* MakeLauncher C:\cygwin64\tmp\MMT.exe ..\mmt-icon-1024.png mmt.app de/michab/app/mmt/Mmt
*/
int MakeLauncher(
const path& targetFile,
path targetFile,
const path& iconFile,
const string& moduleName,
const string& startClass
)
{
// Ensure we have an .exe extension.
if (targetFile.extension() != exe_k)
targetFile.replace_extension(exe_k);

cerr << "Creating launcher: " << targetFile << endl;
WriteLauncher(targetFile);

ResourceMgr target{ targetFile };

mob::windows::RtString strings;
cerr << "Adding main class name: " << startClass << endl;

// Covert dot-notation to invocation API conventions.
string actualStartClass{ startClass };
std::replace(
actualStartClass.begin(),
actualStartClass.end(),
'.',
'/');

cerr << "Adding main class name: " << actualStartClass << endl;
strings.Add(
IDS_JAVA_MAIN_CLASS,
startClass);
IDS_JAVA_MAIN_CLASS,
actualStartClass);

cerr << "Adding main module name: " << moduleName << endl;
strings.Add(
IDS_JAVA_MAIN_MODULE,
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.

0 comments on commit a61415e

Please sign in to comment.