sanity
sanity

Reputation: 35772

How can I provide a telnet interface to my Java application?

I want to provide a telnet interface to my Java application, primarily so that developers can interact with the app, view debugging information, etc - before we've implemented our full end-user facing GUI.

Can anyone recommend an easy and effective way to do this? I've looked at embedding the scala interpreter, but it doesn't seem to be accessible via telnet. Ditto for Beanshell (which I'm not too keen on anyway as I believe its unmaintained).

Upvotes: 4

Views: 2190

Answers (5)

Archie
Archie

Reputation: 5421

I faced this same issue and came up with a slightly ugly combination of nvt4j (telnet server code) plus JLine (Java command line history editor, tab completion, etc.). My application listens on localhost for telnet connections and runs a CLI console loop when it gets a connection.

One key trick is to get the rows and columns information (which is sent via the telnet protocol) transferred from nvt4j to JLine so things don't go haywire when you reach the end of the line.

Upvotes: 0

Christian d'Heureuse
Christian d'Heureuse

Reputation: 5630

If you only need a line-mode interface via Telnet, you could use my Java class TelnetStdioRedirector.

Upvotes: 0

Will Iverson
Will Iverson

Reputation: 2069

Couple of options:

  • Grizzly for embedding a generic server (http://grizzly.java.net/)
  • Mina is another similar option (http://mina.apache.org/)

Instead of Telnet, it might be easier to just embed a web server. Not that a CLI isn't cool and all, but it might be a bit easier/more friendly.

JMX is great for monitoring but the UI isn't very good for 'writing' data. NetBeans has some nice tutorial projects in it.

I think of all of the options above the embedded Jetty is probably the easiest.

Upvotes: 1

Jberg
Jberg

Reputation: 945

Have you considered using JMX? It's built right into the jdk and can provide remote access via jconsole to any methods you configure it too.

Now it's not going to work exactly like ssh or telnet, so it might not meet your needs fully. But if your goals is access to invoking methods and debugging information remotely, that's kind of it's main purpose.

The bonus is after you build a UI you can still use the JMX stuff to monitor performance after it's goes live.

Upvotes: 1

Umesh Kacha
Umesh Kacha

Reputation: 13666

Try Jsh its good for telnet related stuff.

Upvotes: 0

Related Questions