kali linux是默认安装java环境的,那么他该怎么样运行其他平台下的java软件呢?
一:我们先在windows下编写一个小小的java程序。
附上源码:
package kali;
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Kinux extends JFrame {
private JPanel contentPane;
private JTextField textField;
private JPasswordField passwordField;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Kinux frame = new Kinux();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Kinux() {
setTitle("bbskali");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
textField = new JTextField();
textField.setText("用户名");
textField.setBounds(117, 47, 196, 30);
contentPane.add(textField);
textField.setColumns(10);
passwordField = new JPasswordField();
passwordField.setToolTipText("密码");
passwordField.setBounds(117, 94, 196, 30);
contentPane.add(passwordField);
JButton btnNewButton = new JButton("登录");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
Object[] options = { "OK", "CANCEL" };
JOptionPane.showOptionDialog(null, "请输入用户名", "错误提示",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
}
});
btnNewButton.setBounds(117, 150, 93, 23);
contentPane.add(btnNewButton);
JButton btnNewButton_1 = new JButton("退出");
btnNewButton_1.setBounds(220, 150, 93, 23);
contentPane.add(btnNewButton_1);
}
}
二:生成可运行的jar程序。
如图,在windows下我们运行java程序,效果如下:
一个简单的登录窗口。
那么,我们如何在linux
下运行我们的java
程序呢?
三:kali 下运行jar
我们只需要执行命令:
java -jar xxx.jar
这样,我们的java程序也就在kali下运行