public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Example of importing a jar (from ~/.m2/repository)
@ 2021-08-05  0:21 Phil Eaton
  2021-08-05  5:43 ` Alcides Flores Pineda
  0 siblings, 1 reply; 6+ messages in thread
From: Phil Eaton @ 2021-08-05  0:21 UTC (permalink / raw)
  To: kawa

Hey folks,

New to Java and Kawa. I'm trying to import a web server library that I
installed through maven.

The minimal program I'm running is this (test.scm):

(import (class io.jooby Context))


And I run it by making all maven jars available in the CLASSPATH:

CLASSPATH="$(find ~/.m2/repository -name '*.jar' | paste -sd ';');." kawa
test.scm


But I get:

test.scm:2:16: no class found named io.jooby.Context


The io.jooby:jooby jar is
at ~/.m2/repository/io/jooby/jooby/2.10.0/jooby-2.10.0.jar.

What more should I do for Kawa to find the class?

Thanks!
Phil

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Example of importing a jar (from ~/.m2/repository)
  2021-08-05  0:21 Example of importing a jar (from ~/.m2/repository) Phil Eaton
@ 2021-08-05  5:43 ` Alcides Flores Pineda
  2021-08-05 14:02   ` Phil Eaton
  0 siblings, 1 reply; 6+ messages in thread
From: Alcides Flores Pineda @ 2021-08-05  5:43 UTC (permalink / raw)
  To: Phil Eaton; +Cc: kawa

Hi Phil:

If you are just running Kawa from the command line and all that you want
is to use/test some library (from a local Maven repository or not) in the
Kawa REPL, then you can just copy or symlink all the needed JAR files,
(including `kawa.jar`) into a specific directory, and then tell java to
run them from there. 

For example, suppose I want to use the Apache Commons Codec
library from my local Maven repo ($HOME/.m2/repository) in a Kawa REPL,
then, what I do is the following:

1. I copy or symlink the required file along with `kawa.jar`)
($HOME/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar)
into a directory (say for example $HOME/lib).

2. From there run as:
cd $HOME/lib
java -cp $HOME/lib/commons-codec-1.10.jar:$HOME/lib/kawa.jar kawa.repl

3. Now I can use the DigestUtils class from the Kawa repl as:
#|kawa:1|# (import (class org.apache.commons.codec.digest DigestUtils))
#|kawa:2|# (DigestUtils:md5-hex "mystring")
169319501261c644a58610f967e8f9d0

The same stuff applies if you want to run/use it from a Kawa scheme script.

On the other side, if you need/want to use more than a library/JAR (say 
a framework like Spring) with Kawa in a Maven project and run it from 
there, then I suggest you to do the following:

1. Use the Kawa Maven plugin that Arvydas wrote last year to compile
   your Kawa scheme files:
   * https://github.com/arvyy/kawa-maven-plugin

2. Configure your POM (pom.xml) in such a way that it uses the desired
   libraries/dependencies and the `kawa.jar` to compile and run your Kawa scheme
   files, for example with the Maven Ant-Run plugin and the Exec Maven plugin.


Greetings.
-- 
Alcides Flores Pineda.


El mié, ago 04 2021, Phil Eaton escribió:

> Hey folks,
>
> New to Java and Kawa. I'm trying to import a web server library that I
> installed through maven.
>
> The minimal program I'm running is this (test.scm):
>
> (import (class io.jooby Context))
>
>
> And I run it by making all maven jars available in the CLASSPATH:
>
> CLASSPATH="$(find ~/.m2/repository -name '*.jar' | paste -sd ';');." kawa
> test.scm
>
>
> But I get:
>
> test.scm:2:16: no class found named io.jooby.Context
>
>
> The io.jooby:jooby jar is
> at ~/.m2/repository/io/jooby/jooby/2.10.0/jooby-2.10.0.jar.
>
> What more should I do for Kawa to find the class?
>
> Thanks!
> Phil


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Example of importing a jar (from ~/.m2/repository)
  2021-08-05  5:43 ` Alcides Flores Pineda
@ 2021-08-05 14:02   ` Phil Eaton
  2021-08-05 15:54     ` Arvydas Silanskas
  0 siblings, 1 reply; 6+ messages in thread
From: Phil Eaton @ 2021-08-05 14:02 UTC (permalink / raw)
  To: Alcides Flores Pineda; +Cc: kawa

Hey Alcides!

Thanks for the response. Why do I need to _both_ cp or symlink a jar into
$HOME/lib and also set -classpath? Why can't I leave it in its current
place and just set -classpath?

Also, I already set $CLASSPATH to the location of the jar. Isn't that the
same thing as setting -classpath?

Thanks!
Phil

On Thu, Aug 5, 2021 at 1:43 AM Alcides Flores Pineda <alcides.fp@gmail.com>
wrote:

> Hi Phil:
>
> If you are just running Kawa from the command line and all that you want
> is to use/test some library (from a local Maven repository or not) in the
> Kawa REPL, then you can just copy or symlink all the needed JAR files,
> (including `kawa.jar`) into a specific directory, and then tell java to
> run them from there.
>
> For example, suppose I want to use the Apache Commons Codec
> library from my local Maven repo ($HOME/.m2/repository) in a Kawa REPL,
> then, what I do is the following:
>
> 1. I copy or symlink the required file along with `kawa.jar`)
>
> ($HOME/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar)
> into a directory (say for example $HOME/lib).
>
> 2. From there run as:
> cd $HOME/lib
> java -cp $HOME/lib/commons-codec-1.10.jar:$HOME/lib/kawa.jar kawa.repl
>
> 3. Now I can use the DigestUtils class from the Kawa repl as:
> #|kawa:1|# (import (class org.apache.commons.codec.digest DigestUtils))
> #|kawa:2|# (DigestUtils:md5-hex "mystring")
> 169319501261c644a58610f967e8f9d0
>
> The same stuff applies if you want to run/use it from a Kawa scheme script.
>
> On the other side, if you need/want to use more than a library/JAR (say
> a framework like Spring) with Kawa in a Maven project and run it from
> there, then I suggest you to do the following:
>
> 1. Use the Kawa Maven plugin that Arvydas wrote last year to compile
>    your Kawa scheme files:
>    * https://github.com/arvyy/kawa-maven-plugin
>
> 2. Configure your POM (pom.xml) in such a way that it uses the desired
>    libraries/dependencies and the `kawa.jar` to compile and run your Kawa
> scheme
>    files, for example with the Maven Ant-Run plugin and the Exec Maven
> plugin.
>
>
> Greetings.
> --
> Alcides Flores Pineda.
>
>
> El mié, ago 04 2021, Phil Eaton escribió:
>
> > Hey folks,
> >
> > New to Java and Kawa. I'm trying to import a web server library that I
> > installed through maven.
> >
> > The minimal program I'm running is this (test.scm):
> >
> > (import (class io.jooby Context))
> >
> >
> > And I run it by making all maven jars available in the CLASSPATH:
> >
> > CLASSPATH="$(find ~/.m2/repository -name '*.jar' | paste -sd ';');." kawa
> > test.scm
> >
> >
> > But I get:
> >
> > test.scm:2:16: no class found named io.jooby.Context
> >
> >
> > The io.jooby:jooby jar is
> > at ~/.m2/repository/io/jooby/jooby/2.10.0/jooby-2.10.0.jar.
> >
> > What more should I do for Kawa to find the class?
> >
> > Thanks!
> > Phil
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Example of importing a jar (from ~/.m2/repository)
  2021-08-05 14:02   ` Phil Eaton
@ 2021-08-05 15:54     ` Arvydas Silanskas
  2021-08-05 16:11       ` Duncan Mak
  0 siblings, 1 reply; 6+ messages in thread
From: Arvydas Silanskas @ 2021-08-05 15:54 UTC (permalink / raw)
  To: Phil Eaton; +Cc: Alcides Flores Pineda, kawa mailing list

Hello,

You should use `:` as a classpath separator on linux, not `;`.

Arvydas

2021-08-05, kt, 17:02 Phil Eaton <phil@eatonphil.com> rašė:

> Hey Alcides!
>
> Thanks for the response. Why do I need to _both_ cp or symlink a jar into
> $HOME/lib and also set -classpath? Why can't I leave it in its current
> place and just set -classpath?
>
> Also, I already set $CLASSPATH to the location of the jar. Isn't that the
> same thing as setting -classpath?
>
> Thanks!
> Phil
>
> On Thu, Aug 5, 2021 at 1:43 AM Alcides Flores Pineda <alcides.fp@gmail.com
> >
> wrote:
>
> > Hi Phil:
> >
> > If you are just running Kawa from the command line and all that you want
> > is to use/test some library (from a local Maven repository or not) in the
> > Kawa REPL, then you can just copy or symlink all the needed JAR files,
> > (including `kawa.jar`) into a specific directory, and then tell java to
> > run them from there.
> >
> > For example, suppose I want to use the Apache Commons Codec
> > library from my local Maven repo ($HOME/.m2/repository) in a Kawa REPL,
> > then, what I do is the following:
> >
> > 1. I copy or symlink the required file along with `kawa.jar`)
> >
> >
> ($HOME/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar)
> > into a directory (say for example $HOME/lib).
> >
> > 2. From there run as:
> > cd $HOME/lib
> > java -cp $HOME/lib/commons-codec-1.10.jar:$HOME/lib/kawa.jar kawa.repl
> >
> > 3. Now I can use the DigestUtils class from the Kawa repl as:
> > #|kawa:1|# (import (class org.apache.commons.codec.digest DigestUtils))
> > #|kawa:2|# (DigestUtils:md5-hex "mystring")
> > 169319501261c644a58610f967e8f9d0
> >
> > The same stuff applies if you want to run/use it from a Kawa scheme
> script.
> >
> > On the other side, if you need/want to use more than a library/JAR (say
> > a framework like Spring) with Kawa in a Maven project and run it from
> > there, then I suggest you to do the following:
> >
> > 1. Use the Kawa Maven plugin that Arvydas wrote last year to compile
> >    your Kawa scheme files:
> >    * https://github.com/arvyy/kawa-maven-plugin
> >
> > 2. Configure your POM (pom.xml) in such a way that it uses the desired
> >    libraries/dependencies and the `kawa.jar` to compile and run your Kawa
> > scheme
> >    files, for example with the Maven Ant-Run plugin and the Exec Maven
> > plugin.
> >
> >
> > Greetings.
> > --
> > Alcides Flores Pineda.
> >
> >
> > El mié, ago 04 2021, Phil Eaton escribió:
> >
> > > Hey folks,
> > >
> > > New to Java and Kawa. I'm trying to import a web server library that I
> > > installed through maven.
> > >
> > > The minimal program I'm running is this (test.scm):
> > >
> > > (import (class io.jooby Context))
> > >
> > >
> > > And I run it by making all maven jars available in the CLASSPATH:
> > >
> > > CLASSPATH="$(find ~/.m2/repository -name '*.jar' | paste -sd ';');."
> kawa
> > > test.scm
> > >
> > >
> > > But I get:
> > >
> > > test.scm:2:16: no class found named io.jooby.Context
> > >
> > >
> > > The io.jooby:jooby jar is
> > > at ~/.m2/repository/io/jooby/jooby/2.10.0/jooby-2.10.0.jar.
> > >
> > > What more should I do for Kawa to find the class?
> > >
> > > Thanks!
> > > Phil
> >
> >
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Example of importing a jar (from ~/.m2/repository)
  2021-08-05 15:54     ` Arvydas Silanskas
@ 2021-08-05 16:11       ` Duncan Mak
  2021-08-05 17:03         ` Phil Eaton
  0 siblings, 1 reply; 6+ messages in thread
From: Duncan Mak @ 2021-08-05 16:11 UTC (permalink / raw)
  To: Arvydas Silanskas; +Cc: Phil Eaton, kawa mailing list

I find Arvydas's system to work quite well - I'm no fan of a lot of
boilerplate, but it really wasn't too bad.

I was experimenting with Kawa+JavaFX+GraalVM and I made a template here,
really, it's just a pom.xml file:

https://github.com/duncanmak/kawa-javafx-graalvm

I saw that in the Clojure world, there's this deps this:
https://clojure.org/guides/deps_and_cli

I don't know quite how to design it, but I wonder if Arvydas' Maven work
can be added on top of the R7RS module definitions to give us something
similar in Kawa.

What do you think?


Duncan.

On Thu, Aug 5, 2021 at 11:55 AM Arvydas Silanskas via Kawa <
kawa@sourceware.org> wrote:

> Hello,
>
> You should use `:` as a classpath separator on linux, not `;`.
>
> Arvydas
>
> 2021-08-05, kt, 17:02 Phil Eaton <phil@eatonphil.com> rašė:
>
> > Hey Alcides!
> >
> > Thanks for the response. Why do I need to _both_ cp or symlink a jar into
> > $HOME/lib and also set -classpath? Why can't I leave it in its current
> > place and just set -classpath?
> >
> > Also, I already set $CLASSPATH to the location of the jar. Isn't that the
> > same thing as setting -classpath?
> >
> > Thanks!
> > Phil
> >
> > On Thu, Aug 5, 2021 at 1:43 AM Alcides Flores Pineda <
> alcides.fp@gmail.com
> > >
> > wrote:
> >
> > > Hi Phil:
> > >
> > > If you are just running Kawa from the command line and all that you
> want
> > > is to use/test some library (from a local Maven repository or not) in
> the
> > > Kawa REPL, then you can just copy or symlink all the needed JAR files,
> > > (including `kawa.jar`) into a specific directory, and then tell java to
> > > run them from there.
> > >
> > > For example, suppose I want to use the Apache Commons Codec
> > > library from my local Maven repo ($HOME/.m2/repository) in a Kawa REPL,
> > > then, what I do is the following:
> > >
> > > 1. I copy or symlink the required file along with `kawa.jar`)
> > >
> > >
> >
> ($HOME/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar)
> > > into a directory (say for example $HOME/lib).
> > >
> > > 2. From there run as:
> > > cd $HOME/lib
> > > java -cp $HOME/lib/commons-codec-1.10.jar:$HOME/lib/kawa.jar kawa.repl
> > >
> > > 3. Now I can use the DigestUtils class from the Kawa repl as:
> > > #|kawa:1|# (import (class org.apache.commons.codec.digest DigestUtils))
> > > #|kawa:2|# (DigestUtils:md5-hex "mystring")
> > > 169319501261c644a58610f967e8f9d0
> > >
> > > The same stuff applies if you want to run/use it from a Kawa scheme
> > script.
> > >
> > > On the other side, if you need/want to use more than a library/JAR (say
> > > a framework like Spring) with Kawa in a Maven project and run it from
> > > there, then I suggest you to do the following:
> > >
> > > 1. Use the Kawa Maven plugin that Arvydas wrote last year to compile
> > >    your Kawa scheme files:
> > >    * https://github.com/arvyy/kawa-maven-plugin
> > >
> > > 2. Configure your POM (pom.xml) in such a way that it uses the desired
> > >    libraries/dependencies and the `kawa.jar` to compile and run your
> Kawa
> > > scheme
> > >    files, for example with the Maven Ant-Run plugin and the Exec Maven
> > > plugin.
> > >
> > >
> > > Greetings.
> > > --
> > > Alcides Flores Pineda.
> > >
> > >
> > > El mié, ago 04 2021, Phil Eaton escribió:
> > >
> > > > Hey folks,
> > > >
> > > > New to Java and Kawa. I'm trying to import a web server library that
> I
> > > > installed through maven.
> > > >
> > > > The minimal program I'm running is this (test.scm):
> > > >
> > > > (import (class io.jooby Context))
> > > >
> > > >
> > > > And I run it by making all maven jars available in the CLASSPATH:
> > > >
> > > > CLASSPATH="$(find ~/.m2/repository -name '*.jar' | paste -sd ';');."
> > kawa
> > > > test.scm
> > > >
> > > >
> > > > But I get:
> > > >
> > > > test.scm:2:16: no class found named io.jooby.Context
> > > >
> > > >
> > > > The io.jooby:jooby jar is
> > > > at ~/.m2/repository/io/jooby/jooby/2.10.0/jooby-2.10.0.jar.
> > > >
> > > > What more should I do for Kawa to find the class?
> > > >
> > > > Thanks!
> > > > Phil
> > >
> > >
> >
>


-- 
Duncan.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Example of importing a jar (from ~/.m2/repository)
  2021-08-05 16:11       ` Duncan Mak
@ 2021-08-05 17:03         ` Phil Eaton
  0 siblings, 0 replies; 6+ messages in thread
From: Phil Eaton @ 2021-08-05 17:03 UTC (permalink / raw)
  To: Duncan Mak; +Cc: Arvydas Silanskas, kawa mailing list

> You should use `:` as a classpath separator on linux, not `;`.

Doh! This was my issue. I must just have been looking at examples of people
using Windows. Thanks all.

On Thu, Aug 5, 2021 at 12:11 PM Duncan Mak <duncanmak@gmail.com> wrote:

> I find Arvydas's system to work quite well - I'm no fan of a lot of
> boilerplate, but it really wasn't too bad.
>
> I was experimenting with Kawa+JavaFX+GraalVM and I made a template here,
> really, it's just a pom.xml file:
>
> https://github.com/duncanmak/kawa-javafx-graalvm
>
> I saw that in the Clojure world, there's this deps this:
> https://clojure.org/guides/deps_and_cli
>
> I don't know quite how to design it, but I wonder if Arvydas' Maven work
> can be added on top of the R7RS module definitions to give us something
> similar in Kawa.
>
> What do you think?
>
>
> Duncan.
>
> On Thu, Aug 5, 2021 at 11:55 AM Arvydas Silanskas via Kawa <
> kawa@sourceware.org> wrote:
>
>> Hello,
>>
>> You should use `:` as a classpath separator on linux, not `;`.
>>
>> Arvydas
>>
>> 2021-08-05, kt, 17:02 Phil Eaton <phil@eatonphil.com> rašė:
>>
>> > Hey Alcides!
>> >
>> > Thanks for the response. Why do I need to _both_ cp or symlink a jar
>> into
>> > $HOME/lib and also set -classpath? Why can't I leave it in its current
>> > place and just set -classpath?
>> >
>> > Also, I already set $CLASSPATH to the location of the jar. Isn't that
>> the
>> > same thing as setting -classpath?
>> >
>> > Thanks!
>> > Phil
>> >
>> > On Thu, Aug 5, 2021 at 1:43 AM Alcides Flores Pineda <
>> alcides.fp@gmail.com
>> > >
>> > wrote:
>> >
>> > > Hi Phil:
>> > >
>> > > If you are just running Kawa from the command line and all that you
>> want
>> > > is to use/test some library (from a local Maven repository or not) in
>> the
>> > > Kawa REPL, then you can just copy or symlink all the needed JAR files,
>> > > (including `kawa.jar`) into a specific directory, and then tell java
>> to
>> > > run them from there.
>> > >
>> > > For example, suppose I want to use the Apache Commons Codec
>> > > library from my local Maven repo ($HOME/.m2/repository) in a Kawa
>> REPL,
>> > > then, what I do is the following:
>> > >
>> > > 1. I copy or symlink the required file along with `kawa.jar`)
>> > >
>> > >
>> >
>> ($HOME/.m2/repository/commons-codec/commons-codec/1.10/commons-codec-1.10.jar)
>> > > into a directory (say for example $HOME/lib).
>> > >
>> > > 2. From there run as:
>> > > cd $HOME/lib
>> > > java -cp $HOME/lib/commons-codec-1.10.jar:$HOME/lib/kawa.jar kawa.repl
>> > >
>> > > 3. Now I can use the DigestUtils class from the Kawa repl as:
>> > > #|kawa:1|# (import (class org.apache.commons.codec.digest
>> DigestUtils))
>> > > #|kawa:2|# (DigestUtils:md5-hex "mystring")
>> > > 169319501261c644a58610f967e8f9d0
>> > >
>> > > The same stuff applies if you want to run/use it from a Kawa scheme
>> > script.
>> > >
>> > > On the other side, if you need/want to use more than a library/JAR
>> (say
>> > > a framework like Spring) with Kawa in a Maven project and run it from
>> > > there, then I suggest you to do the following:
>> > >
>> > > 1. Use the Kawa Maven plugin that Arvydas wrote last year to compile
>> > >    your Kawa scheme files:
>> > >    * https://github.com/arvyy/kawa-maven-plugin
>> > >
>> > > 2. Configure your POM (pom.xml) in such a way that it uses the desired
>> > >    libraries/dependencies and the `kawa.jar` to compile and run your
>> Kawa
>> > > scheme
>> > >    files, for example with the Maven Ant-Run plugin and the Exec Maven
>> > > plugin.
>> > >
>> > >
>> > > Greetings.
>> > > --
>> > > Alcides Flores Pineda.
>> > >
>> > >
>> > > El mié, ago 04 2021, Phil Eaton escribió:
>> > >
>> > > > Hey folks,
>> > > >
>> > > > New to Java and Kawa. I'm trying to import a web server library
>> that I
>> > > > installed through maven.
>> > > >
>> > > > The minimal program I'm running is this (test.scm):
>> > > >
>> > > > (import (class io.jooby Context))
>> > > >
>> > > >
>> > > > And I run it by making all maven jars available in the CLASSPATH:
>> > > >
>> > > > CLASSPATH="$(find ~/.m2/repository -name '*.jar' | paste -sd ';');."
>> > kawa
>> > > > test.scm
>> > > >
>> > > >
>> > > > But I get:
>> > > >
>> > > > test.scm:2:16: no class found named io.jooby.Context
>> > > >
>> > > >
>> > > > The io.jooby:jooby jar is
>> > > > at ~/.m2/repository/io/jooby/jooby/2.10.0/jooby-2.10.0.jar.
>> > > >
>> > > > What more should I do for Kawa to find the class?
>> > > >
>> > > > Thanks!
>> > > > Phil
>> > >
>> > >
>> >
>>
>
>
> --
> Duncan.
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-08-05 17:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05  0:21 Example of importing a jar (from ~/.m2/repository) Phil Eaton
2021-08-05  5:43 ` Alcides Flores Pineda
2021-08-05 14:02   ` Phil Eaton
2021-08-05 15:54     ` Arvydas Silanskas
2021-08-05 16:11       ` Duncan Mak
2021-08-05 17:03         ` Phil Eaton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).