Skip to main content

juneau-shaded-core

The juneau-shaded-core artifact bundles all core Juneau modules for general marshalling and configuration work. At 2.0 MB, it's the smallest shaded artifact and ideal for applications that don't need REST functionality.

What's Included​

This artifact includes the following Juneau modules:

  • juneau-commons - Core utilities and common classes
  • juneau-config - Configuration file API
  • juneau-marshall - Serializers and parsers (JSON, XML, HTML, MessagePack, etc.)

Serialization Formats Supported​

  • JSON - Multiple flavors (standard, simplified, lax)
  • XML - Standard and namespaced XML
  • HTML - HTML5 and table-based serialization
  • URL-Encoding - URL-encoded form data
  • UON - URL-Encoded Object Notation
  • OpenAPI - OpenAPI-style serialization
  • MessagePack - Binary serialization
  • PlainText - Simple text serialization
  • CSV - Comma-separated values
  • SOAP/XML - SOAP-style XML

Use Cases​

Use juneau-shaded-core when you need:

  • Serialization/Deserialization - Convert POJOs to/from various formats
  • Configuration Management - Use the Config API for application settings
  • Data Transformation - Convert between different data formats
  • No REST APIs - You don't need REST client or server functionality
Maven
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-shaded-core</artifactId>
<version>${juneau.version}</version>
</dependency>
Bazel
# rules_jvm_external (MODULE.bazel / WORKSPACE maven.install)
maven.install(
artifacts = [
"org.apache.juneau:juneau-shaded-core:10.0.0",
],
)
Jarjuneau-shaded-core-10.0.0.jar
LinksMaven Central · Javadocs · Source

External Dependencies​

juneau-shaded-core requires the following external dependencies:

Optional​

  • Jakarta XML Bind API 3.0+ - For XML serialization support

Example Usage​

Basic Serialization​

import org.apache.juneau.marshall.json.*;
import org.apache.juneau.marshall.xml.*;

public class SerializationExample {
public static void main(String[] args) throws Exception {
Person person = new Person("John Smith", 42);

// Serialize to JSON
String json = Json.of(person);
System.out.println(json);
// Output: {name:"John Smith",age:42}

// Serialize to XML
String xml = Xml.of(person);
System.out.println(xml);
// Output: <object><name>John Smith</name><age>42</age></object>

// Parse back from JSON
Person p2 = Json.to(json, Person.class);
}
}

Configuration Management​

import org.apache.juneau.config.*;

public class ConfigExample {
public static void main(String[] args) throws Exception {
Config config = Config.create("myapp.cfg").build();

// Get values with defaults
String host = config.get("Server/host").orElse("localhost");
int port = config.get("Server/port").asInteger().orElse(8080);

// Set values
config.set("Server/host", "example.com");
config.commit();
}
}

Performance Characteristics​

  • Serialization: Fast, memory-efficient
  • Parsing: Safe from deserialization attacks
  • JAR Size: 2.0 MB (smallest shaded artifact)
  • Startup Time: Minimal - no classpath scanning or code generation

Migration from Individual Modules​

If you're currently using individual core modules:

Before:

<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-marshall</artifactId>
<version>${juneau.version}</version>
</dependency>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-config</artifactId>
<version>${juneau.version}</version>
</dependency>
<!-- ... more dependencies -->

After:

<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-shaded-core</artifactId>
<version>${juneau.version}</version>
</dependency>

All imports and API usage remain exactly the same!

Next Steps​