Skip to content

purejava/winsparkle-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

winsparkle-java

winsparkle-java

License Maven Central

Java bindings for WinSparkle in 100% pure Java

Requires

Java 19 (preview)

  • due to the use of the new Foreign Function & Memory API

Usage

The bindings come in two flavors:

Dependency including WinSparkle.dll 0.8.0

<dependency>
    <groupId>org.purejava</groupId>
    <artifactId>winsparkle-java</artifactId>
    <version>1.2.0</version>
</dependency>

WinSparkle.dll gets loaded by the bindings. You don't need to worry about that.

Dependency excluding WinSparkle.dll 0.8.0

<dependency>
    <groupId>org.purejava</groupId>
    <artifactId>winsparkle-java-without-dll</artifactId>
    <version>1.2.0</version>
</dependency>

You need to place WinSparkle.dll in the Java library path yourself and the bindings take care of loading the dll from there.

All of the API function names are the same as the original WinSparkle project.

Initialize WinSparkle

Your app must call win_sparkle_init() somewhere to initialize WinSparkle and perform the check. The best place to do it is as soon after startup as possible, but no sooner than the app's main window is shown. WinSparkle may show its UI soon after this call, so it’s important that the user can immediately associate its updates popup window with your app.

Before calling win_sparkle_init(), you must set the appcast URL with win_sparkle_set_appcast_url():

// Initialize WinSparkle as soon as the app itself is initialized, right
// before entering the event loop:
winsparkle_h.win_sparkle_set_appcast_url("https://winsparkle.org/example/appcast.xml");
winsparkle_h.win_sparkle_init();

Finally, you should shut WinSparkle down cleanly when the app exits:

winsparkle_h.win_sparkle_cleanup();

A note on callbacks

WinSparkle provides a lot of useful callbacks. Using them requires a shared session and to allocate the memory for a callback (aka setting the pointer to a function that is executed as the callback) in the shared session:

// Declare a variable for the session
private MemorySession session;

// Open the session on initializing WinSparkle
session = MemorySession.openShared();

// Pass the session to the static method of the callback when memory for the callback is allocated
win_sparkle_did_not_find_update_callback_t.allocate(yourCallback, session);

// Close the session when WinSparkle is shut down
session.close();

Copyright

Copyright (C) 2022-2024 Ralph Plawetzki

The winsparkle-java logo is made from Icon Fonts and is licensed by CC BY 3.0