Here is an example of the sort of C program one could write in the old days:
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
void main()
{
int gd=DETECT, gm;
initgraph(&gd, &gm, "c:\\turboc\\bgi");
circle(200,100,150);
getch();
closegraph();
}
I think this was turbo C under MSDOS. It gives you a drawing on the screen and can be easily extended to do speedy animated graphics such as those found in xscreensaver hacks.
How would I write the equivalent in gcc on ubuntu? Can it be done in Java?
Ok, few words about basics:
But seriously, I think you're looking at wrong direction. You should focus on modern event-driven GUI programming using modern toolkits (Gtk, Qt), modern languages (C++, C#, Java, Python, etc) and OpenGL for "special effects".
You need to understand that on Linux graphics is generally done thru X11 (perhaps Wayland could become a competitor in the future).
Then you should use some X11 toolkit. If you want it in C, consider GTK or libSDL. But if you know C++, I would recommend Qt (read about its graphics abilities).
You can find some short Qt or Gtk or SDL example programs, in about a hundred lines.
Java has at least Swing.
Notice that Linux is intrinsically a multi-tasking system. So you want to run several graphical programs. In other words, you want several windows (and a window or desktop manager). So, you need an event loop, and you need to take care of resized and/or overlapping windows. Hence the complexity is much bigger than in the TurboC days of the previous century!
Alternatively, consider making your application a specialized HTTP server (and code the graphics in HTML5), e.g. using libonion as a C HTTP server library.