Below is the code i have written and i have compiled without error and load it into oracle via loadjava with -thin and -resolve option.

public class functions{
public static double convertDist(double appDist,char unit)
{
double converted=0;
double tempDist=0;
char tempUnit;

tempDist=appDist;
tempUnit=Character.toUpperCase(unit);

if (tempUnit=='M')
converted=appDist;
else if (tempUnit=='F')
converted=(appDist*0.3048);
else if (tempUnit=='I')
converted=(appDist*0.0254);
else if (tempUnit=='L')
converted=(appDist*0.2011678249);
else if (tempUnit=='D')
converted=(appDist*2.01168);
return converted;
}
}

and i published in oracle like this via sqlplus

create or replace function convertDst(appDist number, unit char) return number as language java name 'functions.convertDist(double,char) return java.lang.Double';

however i couldn't call the function. this is the result:

SQL>variable dist number
SQL> call convertDst(100,'M') into :dist;
call convert(100,'M') into :dist
*
ERROR at line 1:
ORA-29531: no method convertDist in class functions

-----------------------------------------------------------------------------------

However i managed to change somethings but the result is not of what i have wanted.

public class functions{
public static double convertDist(double appDist,String unit)
{
double converted=0;
double tempDist=0;
String tempUnit;

tempDist=appDist;
tempUnit=unit;

if (tempUnit=='M'||tempUnit=='m')
converted=appDist;
else if (tempUnit=='F'||tempUnit=='f')
converted=(appDist*0.3048);
else if (tempUnit=='I'||tempUnit=='i')
converted=(appDist*0.0254);
else if (tempUnit=='L'||tempUnit=='l')
converted=(appDist*0.2011678249);
else if (tempUnit=='D'||tempUnit=='d')
converted=(appDist*2.01168);
return converted;
}
}

and published it like this

create or replace function convertDst(appDist number, unit char) return number as language java name 'functions.convertDist(double,java.lang.String) return java.lang.Double';

SQL>variable dist number
SQL> call convertDst(100,'M') into :dist;

Call completed.

SQL> print x;

X
----------
0 <-- it should be 100 and not 0!


Anyone can help me out, i would highly appreciate it. Thanks!