Package org.nordstjernen
Class Nordstjernen
java.lang.Object
org.nordstjernen.Nordstjernen
Entry point for embedding the Nordstjernen browser engine from Java.
This is a thin JNI veneer over the C embedding API (libnordstjernen.h).
The engine relies on a single GLib main context and is not
safe for concurrent use across threads; drive it from one thread and treat
Page instances as non-thread-safe. Always close() a page
(it owns native memory); shutdown() releases process-wide engine
state.
try (Page page = Nordstjernen.open("https://example.com", 360, 600)) {
System.out.println(page.title());
page.renderToFile(Path.of("example.png"));
}
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault settle time (ms) for the one-shot convenience methods. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinit()Initialize the engine (idempotent).Openurl, collect its links, and close.static PageFetch, parse, lay out and scripturl, returning aPage.static voidsaveScreenshot(String url, int viewportWidthCss, Path out) Openurl, render the whole page to a PNG/PDF file, and close.static BufferedImagescreenshot(String url, int viewportWidthCss, double scale) Openurl, render the whole page to an image, and close.static voidshutdown()Release process-wide engine state.static StringOpenurl, extract its text, and close.
-
Field Details
-
DEFAULT_SETTLE_MS
public static final int DEFAULT_SETTLE_MSDefault settle time (ms) for the one-shot convenience methods.- See Also:
-
-
Method Details
-
init
public static void init()Initialize the engine (idempotent). Loads the native libraries on first call. -
shutdown
public static void shutdown()Release process-wide engine state. After this,init()re-initializes. -
open
Fetch, parse, lay out and scripturl, returning aPage.- Parameters:
url- absolute URL,about:page,data:URL or local pathviewportWidthCss- layout viewport width in CSS pixels (e.g. 360 for a phone)settleMs- milliseconds to let scripts/animations settle before layout- Returns:
- an open page; the caller must
Page.close()it - Throws:
NordstjernenException- if the page cannot be opened
-
screenshot
Openurl, render the whole page to an image, and close. -
saveScreenshot
Openurl, render the whole page to a PNG/PDF file, and close. -
textOf
Openurl, extract its text, and close. -
linksOf
Openurl, collect its links, and close.
-