-2
I compiled my code and everything and when I will open the file .jar
valet says A JNI error has occured
cmd:
C:\Projetos\Java\Projetos\Projeto02>java -jar Gerar.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: principal has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Code:
import java.io.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.text.*;
class principal {
public static void main(String[] args){
/*cria o layout e a janela */
JFrame frame = new JFrame("Gerador");
JPanel panel = new JPanel(new GridBagLayout());
/*JLabel do lado dos objetos*/
GridBagConstraints gbc8 = new GridBagConstraints();
gbc8.anchor = GridBagConstraints.EAST;
gbc8.gridx = 0;
gbc8.gridy = 0;
JLabel itml = new JLabel("Nome do Arquivo:");
panel.add(itml, gbc8);
/*Cria e posiciona o JTextField*/
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.anchor = GridBagConstraints.WEST;
gbc1.gridx = 1;
gbc1.gridy = 0;
JTextField texto = new JTextField();
texto.setColumns(10);
panel.add(texto, gbc1);
/*Cria e posiciona o JComboBox*/
String[] items = {".txt", ".java", ".html", ".php", ".xml", ".odt", ".ods", ".jar", ".sql", ".pdf"};
JComboBox combo = new JComboBox(items);
combo.setBackground(Color.WHITE);
GridBagConstraints gbc2 = new GridBagConstraints();
gbc2.anchor = GridBagConstraints.WEST;
gbc2.gridx = 1;
gbc2.gridy = 1;
panel.add(combo, gbc2);
/*JLabel do lado dos objetos*/
GridBagConstraints gbc9 = new GridBagConstraints();
gbc9.anchor = GridBagConstraints.EAST;
gbc9.gridx = 0;
gbc9.gridy = 1;
JLabel itm2 = new JLabel("Extens\u00e3o:");
panel.add(itm2, gbc9);
/*Cria e posiciona o JButton*/
GridBagConstraints gbc3 = new GridBagConstraints();
gbc3.anchor = GridBagConstraints.WEST;
gbc3.gridx = 1;
gbc3.gridy = 2;
JButton butao = new JButton("Gerar");
panel.add(butao, gbc3);
butao.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
String arquivo = texto.getText() + combo.getSelectedItem();
File file = new File(arquivo);
texto.setText("");
combo.setSelectedIndex(0);
try{file.createNewFile();}catch(IOException ex){ex.printStackTrace();}
}
});
/*Configurações da janela*/
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.setSize(250, 250);
frame.getContentPane().add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
How are you riding that jar?
– user28595
I’m compiling by cmd:
jar cfe Gerar.jar principal principal.class principal$1.class "Gerador de arquivos.java"
– Shintaro
Where did you get this command? And how is the manifest?
– user28595
I always used this command to generate my . jar and all worked and manifest this
Main-Class: principal
– Shintaro
Add the complete stack of errors, because for sure it’s not just a row or error.
– user28595
added the 2 errors when I click 2 in the file . jar it appears 2 windows each with 1 error.
– Shintaro