Archived
This forum has been archived. Please start a new discussion on GitHub.
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:
Please could somebody explain in short words what are the main things to look at.
Thank you very much !!!!
surfer
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:
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
0
Comments
-
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,
Dwayne0 -
How can the client invoke the method?
Hi and thanks but how invokes the client the method?
That's my Client changes:printer.printString("Hello World!"); printer.getDate("Test");
that's my Printerl changes: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:interface Printer { void printString(string s); void getDate(string st); };
What could be the mistake ??
Thanks a lot.
surfer0 -
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, Matthew0 -
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
surfer0 -
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.
e0 -
0
-
epallazz wrote: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"?
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,
- Mark0 -
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,
- Mark0