JEmoji is a lightweight and fast emoji library for Java with a complete list of all emojis from the unicode consortium.
While several other emoji libraries for Java exist, most of them are incomplete or outdated. JEmoji, on the other hand, offers a complete list of all emojis from the Unicode Consortium, which can be generated quickly and easily with just one task. This is a major advantage over other libraries that may be no longer maintained or require extensive manual work to update their emoji lists.
In addition, the data is fetched from multiple sources to ensure that information about each emoji is enhanced as much as possible.
- unicode.org for all unicode emojis
- EmojiTerra for additional information about emojis like aliases
- discord-emoji by Emzi0767 for additional information about emojis for Discord
Replace the VERSION
with the latest version shown at the start of the README
implementation("net.fellbaum:jemoji:VERSION")
<dependency>
<groupId>net.fellbaum</groupId>
<artifactId>jemoji</artifactId>
<version>VERSION</version>
</dependency>
Set<Emoji> emojis = EmojiManager.getAllEmojis();
Optional<Emoji> emoji = EmojiManager.getEmoji("😀");
Optional<Emoji> emoji = EmojiManager.getByAlias("smile");
// or
Optional<Emoji> emoji = EmojiManager.getByAlias(":smile:");
Set<Emoji> emojis = EmojiManager.getAllEmojisByGroup(EmojiGroup.SMILEYS_AND_EMOTION);
Set<Emoji> emojis = EmojiManager.getAllEmojisBySubGroup(EmojiSubGroup.ANIMAL_BIRD);
boolean isEmoji = EmojiManager.isEmoji("😀");
boolean containsEmoji = EmojiManager.containsEmoji("Hello 😀 World");
Set<Emoji> emojis = EmojiManager.extractEmojisInOrder("Hello 😀 World 👍"); // [😀, 👍]
String text = EmojiManager.removeAllEmojis("Hello 😀 World 👍"); // "Hello World "
String text = EmojiManager.removeEmojis("Hello 😀 World 👍",Collections.singletonList("😀")); // "Hello World 👍"
String text = EmojiManager.replaceAllEmojis("Hello 😀 World 👍","<an emoji was here>"); // "Hello <an emoji was here> World <an emoji was here>"
String text = EmojiManager.replaceEmojis("Hello 😀 World 👍","<an emoji was here>",Collections.singletonList("😀")); // "Hello <an emoji was here> World 👍"
classDiagram
direction BT
class Emoji {
+ getEmoji() String
+ getUnicode() String
+ getHtmlDecimalCode() String
+ getHtmlHexadecimalCode() String
+ getURLEncoded() String
+ getVariations() List~Emoji~
+ getDiscordAliases() List~String~
+ getGithubAliases() List~String~
+ getSlackAliases() List~String~
+ getAllAliases() List~String~
+ hasFitzpatrickComponent() boolean
+ hasHairStyleComponent() boolean
+ getVersion() double
+ getQualification() Qualification
+ getDescription() String
+ getGroup() EmojiGroup
+ getSubGroup() EmojiSubGroup
}
Benchmark | Mode | Cnt | Score** | Error | Units |
---|---|---|---|---|---|
containsEmoji | avgt | 10 | 4,820 | ± 0,051 | ms/op |
extractEmojisInOrder | avgt | 10 | 4,841 | ± 0,579 | ms/op |
extractEmojisInOrderOnlyEmojisLengthDescending | avgt | 10 | 8,967 | ± 0,054 | ms/op |
extractEmojisInOrderOnlyEmojisRandomOrder | avgt | 10 | 9,364 | ± 0,081 | ms/op |
removeAllEmojis | avgt | 10 | 7,813 | ± 0,454 | ms/op |
replaceAllEmojis | avgt | 10 | 7,213 | ± 0,043 | ms/op |
Click to see the benchmark details
CPU: Intel® Core™ i7-13700K
VM version: JDK 1.8.0_372, OpenJDK 64-Bit Server VM, 25.372-b07
Blackhole mode: full + dont-inline hint (auto-detected, use -Djmh.blackhole.autoDetect=false to disable)
Warmup: 5 iterations, 10 s each
Measurement: 5 iterations, 10 s each
Timeout: 10 min per iteration
Threads: 1 thread, will synchronize iterations
Benchmark mode: Average time, time/op
** Score depends on many factors like text size and emoji count if used as an argument. For this benchmark relatively large files were used. Click Here to see the benchmark code and resources.
The emoji list can be easily generated with the generateEmojis
Gradle task. The generated list will be saved in the
src/main/resources
folder.