I tried the following code and get the error message shown in the comment.
I do not understand what the following explanation/hint means :
"Instances must be obtained from a suitable factory or query method."
What is a factory or query method ?
It might be best to focus on the missing method first: it's a static method of GraphicsEnvironment--you can't just call it without a class reference.
The error message means exactly what it says, though--you can't instantiate a GraphicsEnvironment, you must call a factory method (a method that creates a GraphicsEnvironment) or query method (not sure, but a method that returns a GraphicsEnvironment).
Side note: that first line is useless. After the first line you overwrite the value of fontnames before using its previous contents. Even worse, it has in fact a negative impact. You create a String array with 10,000 elements. Although the elements are all null, there still is space for 10,000 elements.