저는 6 개월 동안 NetBeans를 사용하여이 프로그램을 작업 해 왔으며 그러한 문제를 경험 한 적이 없습니다. 그것은 내가 org.apache.commons 라이브러리를 추가했을 때 시작되었습니다 (온라인 서버에서 시간을 얻기 위해 필요했습니다), 프로그램을 실행할 때 때로는 모든 것이 잘되고 때로는 백그라운드에서 프로세스를 만드는 실행 상태에 매달려 있습니다. 다음은 주요 메서드가있는 클래스입니다.
package samplefx.ctrl;
import java.io.IOException;
import java.net.InetAddress;
import java.sql.Date;
import java.text.ParseException;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.apache.commons.net.ntp.NTPUDPClient;
import org.apache.commons.net.ntp.TimeInfo;
public class Optilight extends Application {
public static EntityManagerFactory emf;
EntityManager em;
@Override
public void start(Stage primaryStage) throws IOException, ParseException {
emf = Persistence.createEntityManagerFactory("SampleFXPU");
String TIME_SERVER = "time-a.nist.gov";
NTPUDPClient timeClient = new NTPUDPClient();
InetAddress inetAddress = InetAddress.getByName(TIME_SERVER);
TimeInfo timeInfo = timeClient.getTime(inetAddress);
long returnTime = timeInfo.getMessage().getTransmitTimeStamp().getTime();
Date time = new Date(returnTime);
Access access = new Access();
String fix = "XC193283R";
String var = access.Y();
Date start = Date.valueOf("2016-08-23");
Date end = Date.valueOf("2016-08-31");
Boolean j = false;
if (start.before(time) && time.before(end)) {
j = true;
}
boolean i = false;
if (fix.equals(var)) {
i = true;
}
if (!j || !i) {
System.exit(0);
}
// load main form in to VBox (Root)
BorderPane mainPane = (BorderPane) FXMLLoader.load(getClass().getResource("/samplefx/view/Login.fxml"));
// add main form into the scene
Scene scene = new Scene(mainPane);
//primaryStage.setTitle("Optilight 2.2.1");
primaryStage.setScene(scene);
primaryStage.initStyle(StageStyle.UNDECORATED);
//primaryStage.setMaximized(true); // make the main form fit to the screen
primaryStage.show();
primaryStage.setOnCloseRequest(e -> {
emf.close();
Platform.exit();
System.exit(0);
});
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}
}
마침내 이것에 대한 답을 찾았습니다. 서버 시간 초과 문제입니다. 이 두 줄을 추가했습니다. timeClient.open(); timeClient.setSoTimeout(5000);
이 줄 뒤에 :NTPUDPClient timeClient = new NTPUDPClient();
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다