For the OAS 10g release you can run the following.
cd $ORACLE_HOME/j2ee/home
$ORACLE_HOME/jdk/bin/java -jar oc4j.jar -version
Oracle Containers for J2EE 10g (10.1.3.4.0) (build RELEASE.26167)
or you can also do
cd $ORACLE_HOME/inventory/ContentsXML
cat comps.xml | grep patchset
This shows the o/p as
cat comps.xml | grep patchset
<PATCHSET NAME="oracle.as.j2ee.patchset" VER="10.1.3.4.0" BUILD_NUMBER="0" RELEASE="Production" INV_LOC="PatchSets/oracle.as.j2ee.patchset/10.1.3.4.0/3/" XML_INV_LOC="PatchSets21/oracle.as.j2ee.patchset/10.1.3.4.0/" ACT_INST_VER="10.1.0.6.0" DEINST_VER="10.1.0.2.0" INSTALL_TIME="2009.Mar.17 09:21:56 IST">
<INFO NAME="helpDir" VAL="PatchSets/oracle/as/j2ee/patchset/v10_1_3_4_0/help/"/>
<INFO NAME="resourceClass" VAL="PatchSets.oracle.as.j2ee.patchset.v10_1_3_4_0.resources.CompRes"/>
<REF NAME="oracle.as.j2ee.patchset" VER="10.1.3.4.0" HOME_IDX="5"/>
For the FMW 11g release perform the following
cd $ORACLE_HOME/inventory/ContentsXML
cat comps.xml | grep patchset
This shows the o/p as
<PATCHSET NAME="oracle.as.soa.top.patchset" VER="11.1.1.3.0" BUILD_NUMBER="0" RELEASE="Production" INV_LOC="PatchSets/oracle.as.soa.top.patchset/11.1.1.3.0/1/" XML_INV_LOC="PatchSets21/oracle.as.soa.top.patchset/11.1.1.3.0/" ACT_INST_VER="11.1.0.8.0" DEINST_VER="11.1.0.0.0" INSTALL_TIME="2010.Aug.06 21:53:00 IST">
<INFO NAME="helpDir" VAL="PatchSets/oracle/as/soa/top/patchset/v11_1_1_3_0/help/"/>
<INFO NAME="resourceClass" VAL="PatchSets.oracle.as.soa.top.patchset.v11_1_1_3_0.resources.CompRes"/>
<REF NAME="oracle.as.soa.top.patchset" VER="11.1.1.3.0" HOME_IDX="5"/>
For the DB you can issue the command ,
$ORACLE_HOME/bin/sqlplus and note down the version details for example ,
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Aug 16 14:24:29 2010
or you can connect to the DB and find out the version details.