#make java import methods from .jar

1 messages · Page 1 of 1 (latest)

loud otter
#

i need to create a jar file that has all the imports for my project, i've tried everything but it just doesn't work.

dry shoreBOT
#

<@&987246399047479336> please have a look, thanks.

dusty bough
#

u seem to have forgotten to share the details

#

no one can help u like that

#

🙂

loud otter
#

it should work but idk why it's buggy

molten oasis
#

That's clearly your mistake. You create the jar without adding the library as a dependency.
Or you have to share more details about your current setup

dusty bough
#

right now people can't help u

#

so ur losing all the momentum from ur post. people click ur thread, see that there is nothing that can be answered currently and then they move along, closing ur thread

loud otter
#

i will do it step by step

#

i'm creating the .jar artifact here

#

once it's created, i drag it to the "libs" folder that i've created

#

Then i right click it and add it as a module library

#

i guess i'm wrong but i should be a library that i can use for my imports by now, but when i try to import this class it doesn't show any library imports from chatlibrary

molten oasis
#

Are you adding the library to the same library?

loud otter
#

honestly i don't even know what i'm doing at this point

#

i just want the imports to come from the jar file not from the other classes

#

it says import from the other package, not from the library

#

so it's not detecting it

molten oasis
#

What would you expect to be the name of the import?

loud otter
#

something that starts with the name of the library

molten oasis
#

The name of the library doesn't matter. It's the package/folder name that matters.

loud otter
#

but it's clearly not retrieving the class from the library as when i remove it from the project it no longer detects anything to import. The library has the class itself, doesn't it?

molten oasis
#

So if you add the library to the same library the library you exported consists of, the name / import path is the same of the classes

#

Imports are not needed if you are on the same package level. Therefore I think you are already using the classes from your library

loud otter
#

this is what i'm trying to import

#

this is what is being detected currently

#

makes sense?

molten oasis
#

Try to rename the package in your current code and try again to import from the library

loud otter
#

now it wiped module-info and it says this

molten oasis
#

That's one reason why it's important to have a namespace for libraries so they don't clash with their paths

loud otter
#

cyclic dependence

molten oasis
#

iirc the module name also needs to be unique

#

But you should clearly separate your library from your to be used code to avoid confusion

loud otter
#

okay i think i've fixed it?

#

but now javafx is crashing

#

it doesn't detect runtime components

#

that's new

#

okay it seems to be working