I think you may be confusing the Apache httpd server (generally simply called "Apache") with the Apache
Tomcat Server. They are 2 quite different programs, and Apache httpd can't execute
Java code except as a cgi program.
CGI can be any command-line executable (non-GUI) application, providing it follows certain rules, such as outputting the results to stdout, including the appropriate HTTP header information.
Two things to be aware of:
1. It can be a real

to debug CGI, since if the CGI app fails, the error messages you get from Apache are both sparse and fairly useless. Not the kind of thing to be undertaken lightly.
2. Java is not a good language for CGI. Since CGI's are, in fact, executable as stand-alone applications (even CGI scripts!), that means that you have to do all the usual things, including starting a JVM.
Every Single Time a request is made to the CGI. This can result in some serious overhead and response-time issues. In fact, Perl and Python have resorted to cheating. There are special Apache modules that accelerate requests for scripts in these languages by eliminating a lot of the startup overhead.
Among the languages you can use to develop CGI's are the OS command shell itself - bash, csh, kch, or whatever. You can use the "shebang" convention to indicate which shell is to be used.
Normally, you'd simply add the ".cgi" extension to your CGI script/program, regardless of what language it was written in. Among other reasons, this makes it easier to secure the site, since it makes a positive indicator that the only valid CGI's are ones whose names end with ".cgi". People have been known to exploit servers that would serve up arbitrary executables.