Выполните класс Groovy в пакете из командной строки

Я закончил на этой странице, удивляясь тому же. Вот что я делаю (что мне не нравится, но, кажется, работает отлично):

HttpContext context = HttpContext.Current;
if (context == null)
{
    HttpRequest request = new HttpRequest(string.Empty, "http://tempuri.org", string.Empty);
    HttpResponse response = new HttpResponse(new StreamWriter(new MemoryStream()));
    context = new HttpContext(request, response);
    HttpContext.Current = context;
}
this.cache = context.Cache;
13
задан Amicable 30 April 2014 в 13:56
поделиться

1 ответ

First of all, package is a reserved keyword, so you can't use it as a a package name.

Second of all, you can't do that in Groovy, since the dot notation is used for classes, not for scripts, so you need a compiled class file to use it.

Still, you can replace the groovy command with java + classpath:

java -cp /usr/share/java/groovy/embeddable/groovy-all-1.6.3.jar:. my.some.MyClass

You can add an alias to it 'g_java' for instance to make it less verbose.

15
ответ дан 2 December 2019 в 00:19
поделиться
Другие вопросы по тегам:

Похожие вопросы: