Help importing java classes

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Help importing java classes

Pedro
Hello , my java version is : openjdk version "1.8.0_252"

And I'm trying to execute this code:
local Io = require "luan:Io.luan"
local print = Io.print
local sera = require "java:src.classe"
print("Hello World")

I want to import the file /src/classe.java . In doing so, I'm getting the following messsage:
Java isn't allowed

Could anyone help me on this issue?

Thanks in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

fschmidt
Administrator
require "java"
local Io = require "luan:Io.luan"
local print = Io.print
local sera = require "java:src.classe"
print("Hello World")
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

Pedro
Thanks Franklin .

Besides that,
module 'java:src.classe' not found
I've tried the classpath solution like described here:
http://forum.luan.ws/Loading-user-defined-java-classes-tp38p40.html

And I'm still getting the same error. Luan's manual says :
"If the chunk doesn't have permission to use Java, then an error is thrown."
Is it the problem? Could you help me on this?
I'm using Ubuntu 18.04 ( Don't know if it is relevant)

Best regards

Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

fschmidt
Administrator
Show me src/classe.java .
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

Pedro
Thanks, Franklin. I'm sending you everything I think might be relevant.
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

fschmidt
Administrator
Is "src" in your classpath?  Show me your CLASSPATH.
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

Pedro
To prints setting and printing CLASSPATH as root and as my user. Sorry, in advance if I am doing an amateur mistake.

Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

fschmidt
Administrator
That looks fine.  Is there a HelloWorld.class file in the helloworld dir?
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

Pedro
There wasn't. After javac, I created the .class and worked fine.
So, the require java:  is for *.class only ? May *.jar s also work?

Thank you very much.
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

fschmidt
Administrator
jar files also work because they are basically just a zip file containing class files.  .java files are source, they aren't runnable.  .class files are runnable.
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

Pedro
Yes. I really appreciate your help.
My main goal is to run Nabble's open source on my local server. I've cloned the source code from hg.luan.ws/nabble .
It wasn't running since I was stuck in luan. Once you helped me, I compiled some *.java files and move forward. Thanks.

Now, I can't compile GlobalJetty.java ; Could I keep getting support here?

I've already post at support.nabble.com, and sent some people private messages.

Thanks again.
Reply | Threaded
Open this post in threaded view
|

Re: Help importing java classes

fschmidt
Administrator
I won't support Nabble here.  This forum is for Luan.  You can post to Nabble support or email me.