简体   繁体   English

java可执行jar文件无法工作到另一台计算机

[英]java executable jar file not working to another computer

I've built a executable JAR file and it executes fine on my PC (windows 10) which has Eclipse installed. 我已经构建了一个可执行的JAR文件,它在安装了Eclipse的我的PC(Windows 10)上执行得很好。 but when I run this file from another PC with same Operating system. 但是当我从具有相同操作系统的另一台PC运行此文件时。 its not working(it can open the browser but not getting the website I mentioned). 它不工作(它可以打开浏览器,但没有得到我提到的网站)。 please Help me. 请帮我。

here is my code: 这是我的代码:

import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JLabel;
import static java.util.concurrent.TimeUnit.SECONDS;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JTextField;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.awt.event.ActionListener;
import java.io.File;
import java.awt.event.ActionEvent;

public class clAutomationWindow {

private JFrame frame;

private String DeriverFilePath;

private JTextField driverPath;


/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
         public void run() {
            try {
                clAutomationWindow window = new clAutomationWindow();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
public clAutomationWindow() {
    initialize();
}

 /**
  * Initialize the contents of the frame.
 */
private void initialize() {
    frame = new JFrame();
     frame.getContentPane().setBackground(Color.WHITE);
     frame.getContentPane().setLayout(null);

    JLabel lblNewLabel = new JLabel("AICT CL- Renew Post Automation ");
     lblNewLabel.setForeground(new Color(102, 102, 102));
     lblNewLabel.setFont(new Font("Centaur", Font.BOLD, 26));
    lblNewLabel.setBounds(24, 11, 378, 43);
     frame.getContentPane().add(lblNewLabel);

     JButton btnNewButton = new JButton("Start Renew");
    btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {




        System.setProperty("webdriver.firefox.marionette",   DeriverFilePath);
        WebDriver browserDeriver = new FirefoxDriver();





            browserDeriver.manage().timeouts().pageLoadTimeout(30, SECONDS);

            browserDeriver.get("https://www.google.com");



        }});
    btnNewButton.setForeground(new Color(102, 102, 102));
    btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 11));
    btnNewButton.setBounds(23, 374, 120, 40);
    frame.getContentPane().add(btnNewButton);

    JButton button = new JButton("Show Driver");
     button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

            JFileChooser Deriverpath = new JFileChooser();
            Deriverpath.showOpenDialog(null);
            File selectFile = Deriverpath.getSelectedFile();
            String placeOfFile= selectFile.getAbsolutePath();
            DeriverFilePath = placeOfFile.replace("\\","\\\\");
            driverPath.setText(placeOfFile);
        }
    });
    button.setForeground(new Color(102, 102, 102));
    button.setFont(new Font("Tahoma", Font.BOLD, 11));
    button.setBounds(24, 182, 120, 40);
    frame.getContentPane().add(button);

    driverPath = new JTextField();
    driverPath.setColumns(10);
    driverPath.setBounds(154, 187, 248, 30);
    frame.getContentPane().add(driverPath);
     frame.setBounds(100, 100, 450, 550);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

} }

I solve this problem. 我解决了这个问题。 selenium.firefox.FirefoxDriver not working with newer version of FireFox. selenium.firefox.FirefoxDriver不使用较新版本的FireFox。 44.0.2 work fine. 44.0.2工作正常。 I hope near future this problem will solved 我希望不久的将来这个问题会解决

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM