Guest skinie18 Posted August 7, 2012 at 05:57 PM Report Share #471681 Posted August 7, 2012 at 05:57 PM (edited) Boas, a minha duvida é simples, como é que eu dentro de um programa java mando o programa executar outro .jar? Eu pensei no assunto e uma das maneira que me surgio foi na altura que quiser executar o .jar importo o mesmo para o programa actual e executo-o dentro do programa que o chama, no entanto nao sei fazer isso. Edited August 7, 2012 at 05:57 PM by Guest Link to comment Share on other sites More sharing options...
KTachyon Posted August 7, 2012 at 06:04 PM Report Share #471684 Posted August 7, 2012 at 06:04 PM (edited) Process process = Runtime.getRuntime().exec("java -jar jar_name.jar"); Edited August 7, 2012 at 06:04 PM by KTachyon “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
Guest skinie18 Posted August 7, 2012 at 06:46 PM Report Share #471687 Posted August 7, 2012 at 06:46 PM Não dá para adicionar a libraria um jar a meio da execução? (Porque o meu programa localiza o .jar durante a execução e eu queria importa-lo e usar as classes dele) Link to comment Share on other sites More sharing options...
KTachyon Posted August 7, 2012 at 08:10 PM Report Share #471698 Posted August 7, 2012 at 08:10 PM É possível, mas penso que tens que as colocar no classpath. Mas o melhor é leres a documentação: http://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html Alternativamente, podes fazer uma pesquisa no Google por ClassLoader e Dynamic Class Loading. “There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.” -- Tony Hoare Link to comment Share on other sites More sharing options...
JSantos Posted August 14, 2012 at 09:31 AM Report Share #472214 Posted August 14, 2012 at 09:31 AM Boas Se usares o eclipse, é fzeres export no file, adicionares, a(s) librarie(s) e à partida tendo o JRM consegues executá-lo. No youtube tens lá uma explicação. https://www.youtube.com/embed/CH39H4GvwWI?feature=oembed Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now