문제

나는 중지한 질문에 대한 솔루션을 찾는 동안 stackoverflow를 사용하고 있지만, 현재의 질문은 유용한 솔루션을 발견하지 못했습니다. 그래서 나는 가입했다.

Java 애플릿을 하나의 인스턴스로만 제한하는 것이 좋습니다. PHP를 사용하여 애플릿을 최종 사용자에게 제공하므로 옵션이 될 수 있습니다.

그러나 애플릿 자체를 통해 Java 애플릿의 실행을 제한 할 수있는 경우 훨씬 더 관심이 있습니다. 저는 Java에 꽤 새로운 것이므로 나는 그런 건축을 찾기 시작할 곳을 정말로 알지 못합니다.

어떤 제안도 인식 할 것입니다.

측면 메모로서 " JavaScript to Laving only. 주어진 URL 가있는 Java 애플릿을위한 한 창은 해결책이 될 것입니다. 애플릿을 응용 프로그램에 포함시키지 않지만 Applet을 제공하는 팝업에 실제로 가길 수는 없습니다.

진심으로, altwouss

편집 :

인스턴스 제한을 명확히합니다. 기계 당 하나의 애플릿 만 넣고 싶습니다.

도움이 되었습니까?

해결책

애플릿을위한 잘 알려진 포트에서 SocketServer를 시작하지 않으십니까?

SocketServer를 열면 다른 하나는 이미 실행중인 사실 때문일 수 있습니다.그런 다음 메시지를 표시 할 수 있습니다.

다른 팁

If you use Java WebStart, then there is the JNLP SingleInstanceService.

Unfortunately, Java does not support named mutexs for locking across processes. However, you could implement a primitive lock by simply creating a File at a know location with a known name when your applet starts. If the file cannot be created, then you know that one already exists because the application has already started once before. To ensure the file is deleted when the application closes, simple call File.deleteOnExit() method.

Something like:

if(file.createNewFile()) {
    file.deleteOnExit();
} else {
    throw new Exception("Instance already running!");
}

Not a perfect solution and certainly has some issues... But it's probably enough for what you are trying to do. Also could look at that FileLock class which could offer a more robust and appropriate solution.

i am not really sure of this will help or not.. but the first thing that comes my mind is.. Is it possible to make the applet a singleton? sorry this is more as a follow up question then an answer...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top