Skip to Content
Former Member
May 31, 2004 at 09:48 PM

Help, Is the sneek preview 6.40 compatible to j2sdk1.4.2_04


I am an experienced ABAPer but absolutely new in JAVA. So after some investigations (and the not successfully try to install it under Linux - no help from SAP), I have successfully installed WAS 6.40 under W2000. Now I'm trying to run 'Creating Your First J2EE Application' from the help. I have done everything with extreme care (and cut and paste) but after editing '' I get always the same Error Message: 'The method narrow(Object, Class) from the type PortableRemoteObject is not static'. PortableRemoteObject is an import, so this should be ok, but it is not.

In the prerequisites is written that j2sdk1.4.2_03 should be installed first. On my sytem j2sdk1.4.2_04 was already installed, so I thought this should be ok and I got no error message during installation.

But now I have the frustrating fact that the simpliest beginners application does not work. I have included the code, and my question is: Is it a typing mistake or is it the wrong sdk??

I have done this three times, but always the same result.

Thanks for every help




  • Created on 31.05.2004


  • To change the template for this generated file go to

  • Window>Preferences>Java>Code Generation>Code and Comments



import javax.naming.InitialContext;





  • @author sapwas


  • To change the template for this generated type comment go to

  • Window>Preferences>Java>Code Generation>Code and Comments


public class CalcProxy {

private Calculator calc;

public void init() throws Exception {

//Lookup the enterprise bean

try {

InitialContext ctx = new InitialContext();

Object ob = ctx.lookup("java:comp/env/ejb/CalculatorBean");

CalculatorHome home =

(CalculatorHome) PortableRemoteObject.narrow(



//Initialize the enterprise bean

calc = home.create();

} catch (Exception e) {

throw new Exception(

"Error instantiating Calculator EJB" + e.toString());



public CalcProxy() throws Exception {



public float getResult(

String firstNumber,

String secondNumber,

String expression)

throws Exception {

float result = 0;

try {

if (firstNumber != null && secondNumber != null) {

//Parse the input parameters

float first = Float.parseFloat(firstNumber);

float second = Float.parseFloat(secondNumber);

int expr = Integer.parseInt(expression);

//Invoke the relevant method of the enterprise bean

switch (expr) {

case 1 :

result = calc.multiply(first, second);


case 2 :

result = calc.divide(first, second);


case 3 :

result = calc.add(first, second);


case 4 :

result = calc.subtract(first, second);




} catch (Exception re) {

throw new Exception("Fill in all required fields with appropriate values!");


//Return the result of the calculation

return result;