File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Keyword Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Keyword" Watch "Keyword" New topic


Muhammad usman shad
Ranch Hand

Joined: Jan 06, 2010
Posts: 30
Can we make our own keywords in java???
If yes then how and if no then why???
Danish Sualeh

Joined: Oct 06, 2005
Posts: 11
Theoretically you could , but you'd have to modify the java compiler and jvm runtime engine.

That being said, the Java Community Process (JCP) has been the mechanism for developing standard technical specifications for Java technology.

Henry Wong

Joined: Sep 28, 2004
Posts: 20532

Well, it depends on how you define "keywords". If your definition is how it is defined in the specification -- meaning reserved words to the Java language, and can't be used as identifiers in your program -- then no, you can't define new keywords.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
David Newton

Joined: Sep 29, 2008
Posts: 12617

You could also use a tool like the Java Syntactic Extender, but it's a *quite* old project (I first used it back in, say, 2003? 2004?) and may not support recent Java source code. It was, however, quite interesting, and (rightfully so) a source of endless consternation for my boss at the time.

So basically the answer is no, because Java is not a language that lends itself to doing such things.

Note that some DSL techniques can sorta-kinda make it look like you're adding keywords, but the syntactic verbosity of Java generally eliminates any usefulness of such trickery.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46387
Not a "beginning" question. Moving thread.
I agree. Here's the link:
subject: Keyword
It's not a secret anymore!