My Oracle Support Banner

javac exits with error "constant string too long" (Doc ID 1328852.1)

Last updated on NOVEMBER 08, 2018

Applies to:

Java SE JDK and JRE - Version 5.0 to 8
Information in this document applies to any platform.


The Java language compiler 'javac' fails to compile Java source code
and exits with error message "constant string too long". Example:

$ javac constant string too long
    String myConst=""+
1 error


You have created new source code or changed existing source code. Example:

public class BigString {
    String myConst = ""+
    "... /* the length of this String is greater or equal than 0xFFFF chars */ ...";

For an actual example see


To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.