Skip to Content
author's profile photo Former Member
Former Member

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;



Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 01, 2004 at 02:46 AM

    Hi Rudolf,

    it's absolute ok to use j2sdk1.4.2_04. The only mistake is, that you choosed the wrong import in case of PortableRemoteObject. Repeating the corresponding lines from the help:

    2. If necessary, correct the formatting of the code lines by choosing Source -> Format from the context menu.

    3. To add the required import statements, position the cursor anywhere in the Java editor and choose Source -> Organize Imports.

    4. Choose <b>javax.rmi.PortableRemoteObject</b> and confirm by choosing Finish.

    You have selected in step 4 instead.

    Hope that helps.



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.