Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 07-07-2005
surfer surfer is offline
Registered User
 
 
Join Date: Jun 2005
Location: Germany
Posts: 38
Angry Add methods to a Java sample ????

Hello,

sorry but I'm a absolut Java ICE beginner.
E.g. demoj\book\printer
The printer example:
How is it possible to add a method getDate()
like the existing printString("Hello World!") method to all files.

I'v added but I've got an error by compiling it with the existing ant script:

Code:
compile:
    [mkdir] Created dir: C:\Ice-2.1.2\demoj\book\printer\classes
    [javac] Compiling 11 source files to C:\Ice-2.1.2\demoj\book\printer\classes

    [javac] Compiling 14 source files to C:\Ice-2.1.2\demoj\book\printer\classes

    [javac] C:\Ice-2.1.2\demoj\book\printer\Client.java:28: cannot find symbol
    [javac] symbol  : method getDate(java.lang.String)
    [javac] location: interface Demo.PrinterPrx
    [javac]         printer.getDate("Test");
    [javac]                ^
    [javac] 1 error

BUILD FAILED
C:\Ice-2.1.2\demoj\book\printer\build.xml:47: Compile failed; see the compiler error output for details.
Please could somebody explain in short words what are the main things to look at.

Thank you very much !!!!
surfer
Reply With Quote
  #2 (permalink)  
Old 07-07-2005
dwayne's Avatar
dwayne dwayne is online now
ZeroC Staff
 
Name: Dwayne Boone
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Jan 2005
Location: St. John's, Newfoundland
Posts: 209
Hi,

You should only need to add the new method to the Printer interface slice definition in Printer.ice and the java implementation of the method in PrinterI.java.

Regards,
Dwayne
Reply With Quote
  #3 (permalink)  
Old 07-07-2005
surfer surfer is offline
Registered User
 
 
Join Date: Jun 2005
Location: Germany
Posts: 38
How can the client invoke the method?

Hi and thanks but how invokes the client the method?

That's my Client changes:
Code:
printer.printString("Hello World!");
printer.getDate("Test");

that's my Printerl changes:
Code:
public class PrinterI extends Demo._PrinterDisp {
    public void
    printString(String s, Ice.Current current)
    {
        System.out.println(s);
    }
    
    public void
    getDate(String st,Ice.Current current)
    {
	System.out.println(st);
    }
    
}

that's my Printer.ice changes:
Code:
interface Printer
    {
	void printString(string s);
             void getDate(string st);
    };
What could be the mistake ??
Thanks a lot.
surfer

Last edited by surfer : 07-07-2005 at 10:16 AM.
Reply With Quote
  #4 (permalink)  
Old 07-07-2005
matthew's Avatar
matthew matthew is online now
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,060
Was the slice file retranslated by slice2java? Try removing all the generated code and the .class files and re-run ant to see what is going on.

Regards, Matthew
Reply With Quote
  #5 (permalink)  
Old 07-07-2005
surfer surfer is offline
Registered User
 
 
Join Date: Jun 2005
Location: Germany
Posts: 38
Hello,
I remove the folders "generated" and "classes" all the time
so that I've only the sample files without these folders.
But I've had an folder called old_files, where my old class and java files are.
That was the problem.

Thank you very much
surfer
Reply With Quote
  #6 (permalink)  
Old 01-18-2006
epallazz epallazz is offline
Registered User
 
 
Join Date: Jan 2006
Posts: 1
In regards to Matthew's reply:

Try removing all the generated code and the .class files and re-run ant to see what is going on.

___

I am running into the same problem and have since removed all the generated .class files. After that, I recompiled my java code and tried to run the server/client, but I am still getting an error. What does it mean to "re-run ant"? Is that different than rebuilding the java code with "javac"? Thanks for your help.

e
Reply With Quote
  #7 (permalink)  
Old 01-18-2006
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Hi,

Please update your signature as described by our revised forum support policy.

Thanks,
- Mark
Reply With Quote
  #8 (permalink)  
Old 01-18-2006
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Quote:
Originally Posted by epallazz
I am running into the same problem and have since removed all the generated .class files. After that, I recompiled my java code and tried to run the server/client, but I am still getting an error. What does it mean to "re-run ant"? Is that different than rebuilding the java code with "javac"?
Matthew suggested that the user re-run ant because the user was modifying one of the demos included with the Ice for Java distribution, and we use ant as our build tool. It's essentially the same as running javac manually on the regenerated code.

The most likely reason for a compile error after changing a Slice file is a CLASSPATH problem, specifically the compiler finds an obsolete definition of a class. If you've removed all of the generated files and compiled class files, recompiled your Slice files and double-checked your CLASSPATH, the next step would be to create a self-contained archive of your project and attach it so that we can take a look at it.

Take care,
- Mark
Reply With Quote
  #9 (permalink)  
Old 01-18-2006
mes's Avatar
mes mes is offline
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
In the Ice for Java demo directories, we place the generated files (i.e., the files created by slice2java) in the "generated" subdirectory. After you modify the Slice definitions, you must re-run slice2java and recompile the source files in the generated subdirectory.

Hope that helps,
- Mark
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Question about proxy's factory methods. rc_hz Help Center 7 09-05-2006 08:58 AM
"NoObjectFactoryException" when call methods in interface by java richardma Help Center 8 12-02-2005 09:46 AM
C# code generated for comparison methods kwaclaw Comments 3 10-11-2005 02:54 PM
Local or server private methods dashie Help Center 6 12-22-2004 03:31 AM
Calling methods of a client from the server Baloo Help Center 2 09-28-2004 06:31 PM


All times are GMT -4. The time now is 10:00 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.