Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I configure my apache instance to simply load *.java files in browser instead of sending it to me as a download?

share|improve this question
up vote 3 down vote accepted

Put this somewhere convenient:

AddType text/plain .java

in your httpd.conf file. You can find this file via:

$ /usr/sbin/apachectl -V | egrep "(HTTPD_ROOT|SERVER_CONFIG_FILE)"
-D HTTPD_ROOT="/etc/httpd"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

(the typical location is /etc/httpd/conf/httpd.conf)

then restart your apache with

/usr/sbin/apachectl graceful
share|improve this answer
Thanks, is there also a way to set this as the default for all "unknown files"? – verhogen Jan 29 '11 at 8:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.