libbrotli jni header #267

Closed
opened 2026-01-29 20:41:07 +00:00 by claunia · 2 comments
Owner

Originally created by @enexusde on GitHub (Dec 17, 2018).

I need to compress in java.

The problem: There is no fast encoder in java.
The idea: Native bind libbrotli to java using JNI. Publish the Java-Class in github.

Example:

Write class:

public class BrotliEncoder {
  public native byte[] encode(byte[] uncompressed, Charset uncompressedEncoding);
}

call javah to create com_google_brotli_BrotliEncoder.h

#include <jni.h>
#ifndef _Included_com_google_brotli_BrotliEncoder
#define _Included_com_google_brotli_BrotliEncoder
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jbyteArray JNICALL Java_com_google_brotli_BrotliEncoder_encode
  (JNIEnv *, jobject, jbyteArray, jobject);
#ifdef __cplusplus
}
#endif
#endif

Implement the header in libbrotli

Originally created by @enexusde on GitHub (Dec 17, 2018). I need to compress in java. The problem: There is no fast encoder in java. The idea: Native bind libbrotli to java using JNI. Publish the Java-Class in github. Example: Write class: ```package com.google.brotli; public class BrotliEncoder { public native byte[] encode(byte[] uncompressed, Charset uncompressedEncoding); } ``` call javah to create `com_google_brotli_BrotliEncoder.h` ``` #include <jni.h> #ifndef _Included_com_google_brotli_BrotliEncoder #define _Included_com_google_brotli_BrotliEncoder #ifdef __cplusplus extern "C" { #endif JNIEXPORT jbyteArray JNICALL Java_com_google_brotli_BrotliEncoder_encode (JNIEnv *, jobject, jbyteArray, jobject); #ifdef __cplusplus } #endif #endif ``` Implement the header in libbrotli
Author
Owner

@eustas commented on GitHub (Dec 17, 2018):

I believe https://github.com/google/brotli/tree/master/java/org/brotli/wrapper/enc is exactly what you want =) Especially Encoder.compress (see https://github.com/google/brotli/blob/master/java/org/brotli/wrapper/enc/Encoder.java#L202)

@eustas commented on GitHub (Dec 17, 2018): I believe https://github.com/google/brotli/tree/master/java/org/brotli/wrapper/enc is exactly what you want =) Especially Encoder.compress (see https://github.com/google/brotli/blob/master/java/org/brotli/wrapper/enc/Encoder.java#L202)
Author
Owner

@enexusde commented on GitHub (Dec 18, 2018):

Looks good.

@enexusde commented on GitHub (Dec 18, 2018): Looks good.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/brotli#267