Gerando o runnable jar no vscode

Opa!
Meu amigos… preciso muito da ajuda de vocês.
Estou trabalhando em um programa para desktop em java usando javafx.
O programa roda super bem no vscode, mas quando exporto o jar e tento executar ele não encontrava a classe main. Resolvi isso e agora ele dá um erro quando tento executar.
Tentei gerar manualmente o jar com o comando jar e ele diz que jar não é um comando valido …

1 curtida

Posta o comando que vc executou e o erro que está acontecendo. (copie o texto e cole aqui, não precisa enviar prints)

Como vai, Lucas?!
Esse é o comando executado no terminal do vscode:
OBS: Esse comando executa o codigo sem erros… Mas ao exportar o codigo para runnable jar perder o caminho do javafx.

PS C:\Users\olive\OneDrive\Documents\PROJETOS\ODTEC\IHM260522> & ‘C:\Program Files\Java\jdk-18.0.1\bin\java.exe’ ‘–module-path’ ‘lib’ ‘–add-modules=javafx.controls,javafx.fxml’ ‘–enable-preview’ ‘-XX:+ShowCodeDetailsInExceptionMessages’ ‘@C:\Users\olive\AppData\Local\Temp\cp_31yz1x64rb9u3tr7ypgsdf2az.argfile’ ‘application.App’

Esse é o comando executado no terminal pelo vscode ao gerar o .jar

Executing task: java: exportjar:default <

[OK] Successfully added the file to the exported jar: application\App.class
[OK] Successfully added the file to the exported jar: application\animation\Efeitos.class
[OK] Successfully added the file to the exported jar: application\controller\CabecoteController.class
[OK] Successfully added the file to the exported jar: application\controller\CncController.class
[OK] Successfully added the file to the exported jar: application\controller\ConfigController.class
[OK] Successfully added the file to the exported jar: application\controller\CorteController.class
[OK] Successfully added the file to the exported jar: application\controller\DesbobinadorController.class
[OK] Successfully added the file to the exported jar: application\controller\EsteiraController.class
[OK] Successfully added the file to the exported jar: application\controller\EtiquetadorController.class
[OK] Successfully added the file to the exported jar: application\controller\ExtratorController.class
[OK] Successfully added the file to the exported jar: application\controller\GeralController.class
[OK] Successfully added the file to the exported jar: application\controller\HomeController$1$1.class
[OK] Successfully added the file to the exported jar: application\controller\HomeController$1.class
[OK] Successfully added the file to the exported jar: application\controller\HomeController.class
[OK] Successfully added the file to the exported jar: application\controller\LoginsController.class
[OK] Successfully added the file to the exported jar: application\controller\ReceitasController.class
[OK] Successfully added the file to the exported jar: application\controller\SegurancaController.class
[OK] Successfully added the file to the exported jar: application\controller\UltrassomController.class
[OK] Successfully added the file to the exported jar: application\controller\VerificadorDeTuboController.class
[OK] Successfully added the file to the exported jar: application\css\style.css
[OK] Successfully added the file to the exported jar: application\fxml\CABECOTE.fxml
[OK] Successfully added the file to the exported jar: application\fxml\CNC.fxml
[OK] Successfully added the file to the exported jar: application\fxml\CONFIG.fxml
[OK] Successfully added the file to the exported jar: application\fxml\CORTE.fxml
[OK] Successfully added the file to the exported jar: application\fxml\DESBOBINADOR.fxml
[OK] Successfully added the file to the exported jar: application\fxml\ESTEIRA.fxml
[OK] Successfully added the file to the exported jar: application\fxml\ETIQUETADOR.fxml
[OK] Successfully added the file to the exported jar: application\fxml\EXTRATOR.fxml
[OK] Successfully added the file to the exported jar: application\fxml\GERAL.fxml
[OK] Successfully added the file to the exported jar: application\fxml\HOME.fxml
[OK] Successfully added the file to the exported jar: application\fxml\LOGINS.fxml
[OK] Successfully added the file to the exported jar: application\fxml\RECEITAS.fxml
[OK] Successfully added the file to the exported jar: application\fxml\SEGURANCA.fxml
[OK] Successfully added the file to the exported jar: application\fxml\SNAP.fxml
[OK] Successfully added the file to the exported jar: application\fxml\ULTRASSOM.fxml
[OK] Successfully added the file to the exported jar: application\fxml\VERIFICADOR_DE_TUBO.fxml
[OK] Successfully added the file to the exported jar: application\utility\Btn_Status.class
[OK] Successfully added the file to the exported jar: application\utility\FxmlLoader.class
[OK] Successfully added the file to the exported jar: application\utility\IHMconfig.class
[OK] Successfully added the file to the exported jar: application\utility\MovXYZ.class
[OK] Successfully added the file to the exported jar: application\utility\ToPanel.class
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote.png
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote1.png
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote2.png
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote3.png
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote4.png
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote5.png
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote6.png
[OK] Successfully added the file to the exported jar: application\img\cabecote\cabecote7.png
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_avanco_recuo_0.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_avanco_recuo_1.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_avanco_recuo_2.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_avanco_recuo_3.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_base_statico_0.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_base_statico_1.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_base_statico_2.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_base_statico_3.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_direita_esquerda_0.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_direita_esquerda_1.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_direita_esquerda_2.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_direita_esquerda_3.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_sobe_desce_0.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_sobe_desce_1.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_sobe_desce_2.PNG
[OK] Successfully added the file to the exported jar: application\img\cnc\cnc_sobe_desce_3.PNG
[OK] Successfully added the file to the exported jar: application\img\corte\Conjunto cortador corpo[770].PNG
[OK] Successfully added the file to the exported jar: application\img\corte\Conjunto cortador lamina[771].PNG
[OK] Successfully added the file to the exported jar: application\img\corte\Conjunto cortador[772].PNG
[OK] Successfully added the file to the exported jar: application\img\corte\corte1.PNG
[OK] Successfully added the file to the exported jar: application\img\corte\corte2.PNG
[OK] Successfully added the file to the exported jar: application\img\corte\Verificador de corte corpo[780].PNG
[OK] Successfully added the file to the exported jar: application\img\corte\Verificador de corte haste[781].PNG
[OK] Successfully added the file to the exported jar: application\img\corte\Verificador de corte[782].PNG
[OK] Successfully added the file to the exported jar: application\img\desbobinador\barreiradeluz.PNG
[OK] Successfully added the file to the exported jar: application\img\desbobinador\carretel.PNG
[OK] Successfully added the file to the exported jar: application\img\desbobinador\carretel_icone.PNG
[OK] Successfully added the file to the exported jar: application\img\desbobinador\fimdecurso.PNG
[OK] Successfully added the file to the exported jar: application\img\desbobinador\guia.PNG
[OK] Successfully added the file to the exported jar: application\img\desbobinador\indutivo_m12.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\Conjunto suporte de fita trazeiro[773].PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\Conjunto Suporte Inferior Do Carretel[774].PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\conjunto_0.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\conjunto_1.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\conjunto_lamina_0.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\conjunto_lamina_1.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\estiquetador_esquerdo_0.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\estiquetador_esquerdo_1.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\Etiquetadora 4 1.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\Etiquetadora 4 2.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\Etiquetadora 4 alternativa.PNG
[OK] Successfully added the file to the exported jar: application\img\etiquetadora\etiquetadora_esquerda.png
[OK] Successfully added the file to the exported jar: application\img\extrator\Base_extrator.PNG
[OK] Successfully added the file to the exported jar: application\img\extrator\Extrator_do_tubo.PNG
[OK] Successfully added the file to the exported jar: application\img\extrator\Garfo.PNG
[OK] Successfully added the file to the exported jar: application\img\extrator\Garfo_Carrinho.PNG
[OK] Successfully added the file to the exported jar: application\img\extrator\Pega_dos_pinos.PNG
[OK] Successfully added the file to the exported jar: application\img\pulmao\Haste pulmão desbobinadeira.PNG
[OK] Successfully added the file to the exported jar: application\img\pulmao\Suporte inferior da polia do pulmão esquerda.PNG
[OK] Successfully added the file to the exported jar: application\img\pulmao\Suporte inferior da polia do pulmão.PNG
[OK] Successfully added the file to the exported jar: application\img\telaprincipal\imgCentral1.png
[OK] Successfully added the file to the exported jar: application\img\ultrassom\Sistema de visão[775].PNG
[OK] Successfully added the file to the exported jar: application\img\ultrassom\Ultrason com sonotrodos corpo[776].PNG
[OK] Successfully added the file to the exported jar: application\img\ultrassom\Ultrason com sonotrodos embolo[777].PNG
[OK] Successfully added the file to the exported jar: application\img\ultrassom\Ultrason com sonotrodos lateral[778].PNG
[OK] Successfully added the file to the exported jar: application\img\ultrassom\Ultrason com sonotrodos[779].PNG
[OK] Successfully added the file to the exported jar: application\img\verificador_tubo\verificador_tubo.PNG
[OK] Successfully added the file to the exported jar: application\db\siemens\especiais\AUTOMATICO.class
[OK] Successfully added the file to the exported jar: application\db\siemens\especiais\CNC_CONTROLE_DB.class
[OK] Successfully added the file to the exported jar: application\db\siemens\especiais\CNC_LISTA_DB.class
[OK] Successfully added the file to the exported jar: application\db\siemens\especiais\FITA_DB.class
[OK] Successfully added the file to the exported jar: application\db\siemens\especiais\FITA_LISTA_DB.class
[OK] Successfully added the file to the exported jar: application\db\siemens\especiais\INDEXADOR.class
[OK] Successfully added the file to the exported jar: application\db\siemens\especiais\SEGURANCA.class
[OK] Successfully added the file to the exported jar: application\db\siemens\generico\ATUADOR.class
[OK] Successfully added the file to the exported jar: application\db\siemens\generico\CONTROLE.class
[OK] Successfully added the file to the exported jar: application\db\siemens\generico\DB.class
[OK] Successfully added the file to the exported jar: application\db\siemens\generico\DESBOBINADOR.class
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede1.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede10.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede11.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede12.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede13.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede14.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede15.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede16.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede17.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede18.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede19.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede2.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede20.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede21.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede22.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede23.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede24.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede3.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede4.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede5.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede6.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede7.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede8.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\indicadores\rede9.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\cabecote.png
[OK] Successfully added the file to the exported jar: application\img\icones\menu\cnc.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\configurações.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\configurações.SLDPRT
[OK] Successfully added the file to the exported jar: application\img\icones\menu\corte.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\desbobinador.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\esteira.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\Etiquetadora.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\extrator.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\logins.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\maquina.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\prancheta_receitas_0.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\prancheta_receitas_1.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\pulmao.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\seguranca.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\menu\seguranca123.png
[OK] Successfully added the file to the exported jar: application\img\icones\menu\UltraSom.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\seguranca\arcomprimido.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\seguranca\emergencia.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\seguranca\portas.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\seguranca\sdrivec43a.PNG
[OK] Successfully added the file to the exported jar: application\img\icones\seguranca\sdrivec511a.PNG
[OK] Successfully extracted the file to the exported jar: commons-codec-1.9.jar
[OK] Successfully extracted the file to the exported jar: javafx-swt.jar
[OK] Successfully extracted the file to the exported jar: javafx.base.jar
[WARNING] duplicate entry: module-info.class
[WARNING] duplicate entry: module-info.class
[WARNING] duplicate entry: module-info.class
[WARNING] duplicate entry: module-info.class
[WARNING] duplicate entry: module-info.class
[WARNING] duplicate entry: module-info.class
[OK] Successfully extracted the file to the exported jar: moka7-live-0.0.13.jar
[WARNING] duplicate entry: module-info.class
[SUCCESS] Export Jar process is finished successfully
O terminal será reutilizado por tarefas, pressione qualquer tecla para fechá-lo.

Erro apresentado ao executar o .jar
PS C:\Users\olive\OneDrive\Documents\PROJETOS\ODTEC\IHM260522> java -jar ‘–enable-preview’ IHM260522.jar
Error: JavaFX runtime components are missing, and are required to run this application

Estão faltando as classes do JavaFX no seu JAR

Obrigado meu amigo staroski!
sim… eu vi :frowning: achei que o vscode copiasse direto para o jar.
A solução que eu encontrei foi adicionar uma pasta lib com os arquivos do javafx na mesma pasta do jar e ainda assim preciso informar o local do fx na linha de comando para rodar o jar… mas funciona

java --module-path lib/javafx-sdk-18.0.1/lib --add-modules javafx.controls,javafx.fxml --enable-preview -jar IHM280522.jar application.Main