• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDK 1.5 MetaData

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Folks I am trying to compile the following code using JDK1.5 compiler, I get the following compiler error...
<-------------------------- Code ------------------------->

public class Ping {
public @remote void ping() {
}
}


<-------------------------- Code ends------------------------->




<-------------------------- Error ------------------------->

C:\jdk1.5.0\test>C:\jdk1.5.0\bin\javac -source 1.5 Ping.java
Ping.java:6: cannot find symbol
symbol : class remote
location: class Ping
public @remote void ping() {
^
1 error


<-------------------------- Code Ends ------------------------->

Any help would be appreciated....
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any takers for this issue?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what you get for using a beta API, not a lot of support.
You can improve your chances by clueing us into what you are trying to do, what packages you are trying to use and so on. The code you provided us doesn't give much context. My wild guess would be that instead of @remote you actually want a class name, say like java.rmi.Remote.
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Santosh Ram,

You need an additional java source file named remote.java.

Inside you should have



Compile these two files and bingo!

Best Regards
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joe I am trying to play with the JSDk1.5 new features and I wanted to use annotation for a simple class.

I changed the code according to what you said but I am getting another error ... (Trying to use the meta data feature as indicated in this article)
http://java.sun.com/developer/technicalArticles/releases/j2se15/

<!----------------- code starts ----------------->
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.rmi.*;
public class Ping {
public @Remote void ping() {
}
}
<!----------------- code ends----------------->



<!----------------- Compiler error start ----------------->


C:\jdk1.5.0\test>C:\jdk1.5.0\bin\javac -source 1.5 Ping.java
Ping.java:5: incompatible types
found : java.rmi.Remote
required: java.lang.annotation.Annotation
@java.rmi.Remote public void ping() {
^
1 error

C:\jdk1.5.0\test>




<!----------------- compiler error ends ----------------->
[ July 02, 2004: Message edited by: Santosh Ram ]
 
Xie Ruchang
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

All annotations must be defined using @interface like

public @interface annotationname {

}

In your example, you annotate as @remote. This must not be confused with the interface java.rmi.Remote. You do not need to import java.rmi.*.

You should have a file remote.java and inside

public @interface remote {

}

In another file when you annotated with the remote tag. The compiler will look for the above.

Bear in mind you deviated from the normal java convention of naming classes with capital letters. You know Java is case-sensitive

Regards
[ July 02, 2004: Message edited by: Frankie Cha ]
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frankie,
The code posted by me second time the uses java.rmi.Remote interface. I am not using my own Interface Class for it.

I get the error even though I use the Remote interface from java.rmi.
[ July 02, 2004: Message edited by: Santosh Ram ]
 
author
Posts: 799
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Sun example is missing relevant code. You'd be better off working from a complete example.

For a more involved explanation and example of annotation types, try http://www.langrsoft.com/articles/annotations.html.

-j-
[ July 06, 2004: Message edited by: Jeff Langr ]
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys!! I still can't compile this piece of code.....
Can someone help me in compiling and running this code?
Any help would be greatly appreciated!!

import java.lang.annotation.*;
import java.lang.reflect.*;
import java.rmi.*;
public class Ping {
public @Remote void ping() {
}
}


<!---------------------compiler error --------------------->

C:\jdk1.5.0\test>C:\jdk1.5.0\bin\javac -source 1.5 Ping.java
Ping.java:5: incompatible types
found : java.rmi.Remote
required: java.lang.annotation.Annotation
public @Remote void ping() {
^
1 error

C:\jdk1.5.0\test>
 
Xie Ruchang
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
// Ping.java
// import java.lang.annotation.*; NOT NECESSARY
// import java.lang.reflect.*; NOT NECESSARY
// import java.rmi.*; COMMENT THIS OUT - NOTHING TO DO WITH ANNOTATION
// CHANGE YOUR MINDSET - READ CAREFULLY MY EARLIER POSTINGS !!!
public class Ping {
public @Remote void ping() {
}
}

// Remote.java
public @interface Remote {

}

Compile the above two files Ping.java and Remote.java. Please
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Frankie!!
Thanks for the help. your code compiles.

If you look at the code for Metadata example in the following link http://java.sun.com/developer/technicalArticles/releases/j2se15/ the author is trying to avoid the boiler plate code by not implementing the Remote interface. Thats what I am trying to do.


With a metadata processing tool, many repetitive coding steps could be reduced to a concise metadata tag. For example, the remote interface required when accessing a JAX-RPC service implementation could be implemented as follows:

Before

public interface PingIF extends Remote {
public void ping() throws RemoteException;
}

public class Ping implements PingIF {
public void ping() {
}
}



After

public class Ping {
public @remote void ping() {
}
}



Can you help in making the after code compile?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As far as I can tell, the example from the article is *hypothetical* - that is, the "after" code *cannot* compile (yet), because the necessary infrastructure (for example the declaration of the annotation) is missing.
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ilja,
Thanks for response. What do you think is needed (what kind of annotation declration)for setting up the infrastructre in order to run the After code.

Santosh
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Santosh Ram:
Ilja,
Thanks for response. What do you think is needed (what kind of annotation declration)for setting up the infrastructre in order to run the After code.

Santosh



Well, for compiling it, you needed the annotation declaration as given by Frankie above. For *running* it as if it declared the Remote interface, I don't know.
 
Tomorrow is the first day of the new metric calendar. Comfort me tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic