Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to compile a project with an external package? #68

Open
gmy2013 opened this issue Sep 6, 2020 · 4 comments
Open

How to compile a project with an external package? #68

gmy2013 opened this issue Sep 6, 2020 · 4 comments

Comments

@gmy2013
Copy link

gmy2013 commented Sep 6, 2020

Hello, thanks for your great job! I have a question on the compilation of Jlang. Since JLang cannot link pre-compiled JAR files, how to compile a project or single java file with a package such as "import org.dom4j.XXX", which is not included in JDK directory?

@andrewcmyers
Copy link
Member

If you have the source for the package, you can compile it using JLang and then link against it.

@gmy2013
Copy link
Author

gmy2013 commented Sep 7, 2020

Thanks for your reply! Since I am not familiar with the components of Jlang, could you please explain it in detail? What is the form of the "source for the package", .java files? How to compile the package using JLang, using the " Building Larger Project " example or re-writing the Makefile to add the packages to JDK? And how to link against the compiled package? Thank you very much!

@Prokksi
Copy link

Prokksi commented Sep 30, 2020

Hi @gmy2013 , did you make any progress in the meantime? I am interested in this usecase as well.

@dz333
Copy link
Collaborator

dz333 commented Nov 3, 2020

At the moment, JLang can only link against standalone dynamically linked libraries. Normal java projects are not standalone libraries as they are bytecode that can be executed only inside a JVM.

If you have the original java source files as a project, then you can compile them using JLang with the "Building Larger Project" example as a starting point. This will produce a dynamically linked library that you can then link against once you have built your original project using JLang.

Note that ALL source files need to be compiled this way, so if your dependency has dependencies, those will also need to be compiled similarly. Obviously this is not tenable for large java projects that import many dependencies but at the moment we do not have a better solution.

In the future, we would like to add a feature where JLang could compile Java bytecode, which would solve many of these problems since we could compile JARed dependencies along with your source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants