Java on Shell

Is there a way to make a java class to act like shell command? Like


> ClassName [parameter] [values]

Similar to “apt-get install whatever”. In current state, we have to include “java” command everytime we call it.

Or it’s impossible so I need to learn bash? :persecutioncomplex:

I think you can run a class file from shell. Think I’ve done it before, can’t remember how.

Alias.


alias ClassName="java ClassName"

Ok I’ll try it.

Another thing,

  1. how to get the java program listed in repository?
  2. how to make the program take over the terminal screen, like when we use nano or other text editors?
  3. Can java program has auto-completion too? (tab key)
  1. Not sure but I’m pretty sure it’s not as simple as submitting a jar since there are strict requirements on the packaging and executing structure.

  2. You can’t.

  3. Not possible with any console application AFAIK.

Take a look at beanshell: http://www.beanshell.org/home.html

But java is not the best shell language, so learning bash might turn out the better decision…

I have looked on beanshell, what exactly is it? I read the intro, quick start, but get no point of its purpose.

Can’t? :wink: Try googling Java terminal curses

This looks like it could be interesting - http://code.google.com/p/lanterna/ - and without native libs too.

There’s also JCurses, though that requires natives.

Ooooh, lanterna looks good!

Kev

You might want to run java as [icode]java -noverify[/icode] for commandline apps that you want to start up quicker. You can also look into nailgun for even faster startup though there’s some security caveats that apply to that.

Huh so with Lantern, to enter private mode, it write a bunch of weird characters out and executes an external process. O_o

well its a shell to script beans - hence java classes. you can run it interactively from the commandline, so youmight get a better environment for interacting with your classes. there is also groovyshell http://groovy.codehaus.org/Groovy+Shell#GroovyShell-Features which might offer more features.

OT: man - I hate posting here from my 2.3 android phone. does it work better with 4.1?

Isn’t that kind of how this whole thing works? :wink: http://en.wikipedia.org/wiki/ANSI_escape_code

An almost immeasurably tiny amount. ;D

@nsigma
That looks great! Unfortunately there’s no example code yet, but I hope it can get along with shell.

@cylab
So that’s it. It seems provide easy way to invoke GUI. However lanterna maybe more suitable for me.