---
title: 'Shortest Java Quine with 106 chars'
url: 'https://tutego.de/blog/javainsel/2007/09/shortest-java-quine-with-106-chars'
markdown: 'https://tutego.de/blog/javainsel/2007/09/shortest-java-quine-with-106-chars.md'
date: '2007-09-06'
description: 'Because of a contest in a German Java forum I tried to formulate the shortest Java Quine: enum _{_;{String _="enum _{_;{String _=%c%s%1$c;System.out.printf(_,34,_);}}";System.out.printf(_,34,_);}} To compile and run under Windows (with Unix you need to redirect Exceptions to /dev/null and use diff)…'
taxonomy:
  category:
    - Allgemein
---

# Shortest Java Quine with 106 chars

![Illustration einer tropischen Insel mit Palmen und einem hohen Berg](https://tutego.de/blog/javainsel/user/themes/tutego/images/insel-cover.jpg)# Java Blog für Programmierer

[Java Blog für Programmierer](https://tutego.de/blog/javainsel/)

## Shortest Java Quine with 106 chars

06.09.2007 · [Christian Ullenboom](https://tutego.de/blog/javainsel/author/admin/)

Because of a contest in a German Java forum I tried to formulate the shortest Java [Quine](http://en.wikipedia.org/wiki/Quine_(computing)):

```java
enum _{_;{String _="enum _{_;{String _=%c%s%1$c;System.out.printf(_,34,_);}}";System.out.printf(_,34,_);}}
```

To compile and run under Windows (with Unix you need to redirect Exceptions to /dev/null and use diff):

```batch
>javac _.java >java _ 2> NUL > Quine.out > fc Quine.out _.java Vergleichen der Dateien Quine.out und _.JAVA FC: Keine Unterschiede gefunden >jrunscript -e "print(new java.io.File('_.java').length())"106
```

I haven’t found a shorter solution on the net, so I suppose this is the shortest for now.

Kategorien: [Allgemein](https://tutego.de/blog/javainsel/category/allgemein/)

[← Alle Beiträge](https://tutego.de/blog/javainsel/)
