Why does one need to publish Java in the database?

Publishing Java classes on the database makes it visible on a SQL and PL/SQL level. It
is important to publish your code before calling it from SQL statements or PL/SQL code.
Look at this example:

        create or replace function hello (str varchar2) return varchar as
           language java name 'Hello.Msg(java.lang.String) return java.lang.String';
        /