INCLUIR DLL NO *.JAR DO INTELLIJ IDEA

Answered

Boa tarde galera,
Eu estou tentando gerar um *.JAR de uma aplicação no IntelliJ Idea de impressão de cheques que utiliza comunicação de porta serial. Eu faço isso através do Build > Build Artifacts..., eu consigo gerar o *.JAR, no entanto quando faço o teste com esse *.JAR que foi gerado, a aplicação não consegue se comunicar com a impressora serial.
DETALHE: Quando executo apertando "Run" ou no modo "Debug", a comunicação funciona perfeitamente.
Só pude deduzir que faltam as DLL's, alguem sabe como faço para incluir DLL's no IntelliJ Idea?

5 comments
Comment actions Permalink

.dll must be in PATH or in a folder that is referenced via -Djava.library.path= JVM option.

Using .dll from inside the jar is possible, but will need to write the code that unpacks it: http://stackoverflow.com/a/4764387/104891.

If you decide to go this route, modify the artifact to include the .dll in the desired location so that your code can unpack and load it: http://www.jetbrains.com/idea/webhelp/configuring-artifacts.html.

0
Comment actions Permalink

Thanks! I've solved part of the problem just debugging my JAR file via command prompt but then I got this error:

The problem here it's that I already changed my JDK to 32 bits, I went in "Project Structure" > "SDK" and I changed the location of the JDK to C:\Program Files (x86)\Java. How do I do to not catch this error again? =/

0
Comment actions Permalink

Sorry for the english :(

0
Comment actions Permalink

Make sure 32-bit JDK is used to run the project.

If you run externally, outside of IDEA, make sure that 32-bit JDK is the first in PATH. You can just uninstall 64-bit JDK and leave only 32-bit version to avoid problems.

Or you can bundle different dll versions with your app and unpack/load the one depending on JDK version that was used to run your app.

0
Comment actions Permalink

It's working! =D

I did what you suggest, I unistalled my 64-bits JDK and just to be sure I installed the 32-bits JDK again! I can't believe that I spent almost two days to solve the problem. =(

And now it's time for testing! Thank you!!!

0

Please sign in to leave a comment.