System.exit(0) closes wrong window
I use a web browser to display an applet.
In the applet I have the possibility to start a new webbrowser window with myapplet.getAppletContext().showDocument(url, "_blank");In the new webpage I also start a new applet.
To close this new web page I call System.exit(0); from the applet in the new page.
The strang thing that happens than is that the parent window is closed and the newly opened web page is still active.
If I open these windows myself in the browser, I can close them from the applet.
Can anybody help.
System.exit is not permitted by an applet for the above mentioned reason.
Multiple browser windows with applets share the same jvm so exiting the
jvm makes the other applets crash.
When you give the applet permission (sign or policy) system.exit will crash
the browser.
It is possible to close a popup window, since I don't beleve in the JSObject
anymore (crashed too many times with too many bugs in mozilla).
You can use another way, here it is.
in your applet// to open the window
this.getAppletContext().showDocument(
new URL("javascript: myPopupWindow = window.open('yourPage.htm');myPopupWindow.focus()"));
// to close the window
this.getAppletContext().showDocument(
new URL("javascript: myPopupWindow.close()"));in your html page:<script>
var myPopupWindow = null;
</script>
Similar Messages
-
System.exit(1)
I use NetBean6.5 , Creme, window mobile 6, to create simple program for learning. I add a button with the System.exit to close out the program. The program closes successfuly but it gives me this error on netBean output:
java.lang.NullPointerException
at org.netbeans.modules.j2me.cdc.project.nsicom.NSIcomExecDeployTask.execute(NSIcomExecDeployTask.java:267)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor80.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:273)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:499)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)
BUILD FAILED (total time: 15 seconds)
Does anyone know why?nevermind just found the solution. Don't use System.exit(1), but use System.exit(0);
-
Denying Thread calling System.exit() successfully
Hi all,
i start another java app from within my code by calling it's main()-method in an own thread.
As i don't have any access to the code of the java app i can't prevent it from calling System.exit() when the corresponding window is closed.
How can i prevent the "threaded" java app from also closing my wrapping application when it is finished?
Greetings,
BernhardYou can install a security manager (your own) in your application and override the method checkExit(int status) in order to handle the event:
class OwnSecurityManager extends SecurityManager{
public void checkExit(int code){
if(code == 1){
super.checkExit(code);
throw new SecurityException("Not allowed here"); //or your handling code
}else{
//other codes
//in your app you install the manager like this
SecurityManager s = new OwnManager();
System.setSecurityManager(s); -
System.exit vs. programm flow
Hellas!
Short question:
Why is
public boolean foo(){
throw new IllegalArgumentException();
}ok, where
public boolean foo(){
System.exit(0);
}is wrong (compiler demands a return statement)? Isn't there no way the exit method returns to the method foo?
TIA, flutschfingerspoon_ wrote:
Technically it can throw a SecurityException:
http://java.sun.com/javase/6/docs/api/java/lang/System.html#exit(int)
So does the first method. The second either exits (the method doesn't return normally) or throws an exception, so I guess it will never return anything.
In any case they are not going to change the Java language to treat the library function System.exit() specially. You can always just put a "return false" after it or something.So it's just a specification thing? -
System.exit(0) will not close the program
uh, for some reason when the conditions inside the processInputString are met, the program fails to shutdown. The msg to console is posted and program hangs when it should close.
public class JPing2 {
public static void main(String[] args) {
String ip = "74.125.67.100"; //google.com
String pingCmd = "ping -t " + ip;
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec(pingCmd);
BufferedReader br = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String inputLine = new String();
while ((inputLine = br.readLine()) != null) {
System.out.println(inputLine);
processInputString(inputLine);
br.close();
} catch (IOException ioe) {
System.out.println(ioe.getMessage());
System.exit(0);
* Parses a string looking for ping failures
static void processInputString(String input) {
String failMsg = new String("Request timed out.");
if (input.equals(failMsg)) {
System.err.println("failure detected");
System.exit(0);
} else if (input.equals("Reply from 74.125.67.100: bytes=32 time=33ms TTL=51")) {
System.err.println("normal operation");
System.exit(0);
}what the hell, am I missing something?
Edited by: rico16135 on Aug 24, 2009 10:17 PMProbably because it's blocked reading the process output and this might be an operation that can't be interrupted.
-
System.exit() causes Firefox to close
Hi.
I have a strange problem - I have an app which can be both an applet and a standalone application. At some point is calls System.exit() and it can happen in an applet too. (It's easy to redesign the code but that;s not my question)
Strange enough (for me at least) the call causes the whole browser to close! (Observed in FF 1.5.x and 2.0, reported in IE7). Is this supposed to happen?
Thanks.No, this isn�t a bug. You should not call System.exit from an applet, instead use the life cycle methods of the Applet class.
-
System.exit(VALUE) and Windows 98?
Has anyone got System.exit(integer) to return a value other than 0 under Windows 98?
Regardless of what integer I enter as an exit code, java.exe always seems to return 0. This does not seem to be the case under Windows NT, where the correct exit code is passed back.
Is anyone aware of this problem/found a workaround?I found the same behaviour of Java between NT 4.0 SP 4 and Windows 98.
Are you sure you get the exit code right in the dos box?
%ERRORLEVEL% is NT specific, I think.
In normal DOS you can only ask e.g.:
if ERRORLEVEL 3 goto three
and this will jump to label
:three
if the exit code is >= 3 !!!
Test your program by this bat file:
java ...
if %errorlevel 6 goto x6
if %errorlevel 5 goto x5
if %errorlevel 4 goto x4
if %errorlevel 3 goto x3
if %errorlevel 2 goto x2
if %errorlevel 1 goto x1
goto x0
:x0
echo was: 0
goto end
:x1
echo was: 1
goto end
:x2
echo was: 2
goto end
:x3
echo was: 3
goto end
:x4
echo was: 4
goto end
:x5
echo was: 5
goto end
:x6
echo was: 6
goto end
:end
echo End.
You see:
7 or higher goes also to :x6 -
Close using system.exit()
could anyone tell me to write a new program which has a button labelled 'close'. when click on 'close', it should terminate the addition program.
import javabook.*;
class addition
public static void main(String args[])
int a, b,c;
MainWindow mainWindow = new MainWindow(); // creates a frame,mainwindow is in javabook package
InputBox inputBox = new InputBox(mainWindow); // creates an inputbox, is in javabook package
OutputBox outputBox = new OutputBox(mainWindow);// creates an outputbox;
outputBox.setVisible(true);
a= inputBox.getInteger("Enter an integer: ");
b=inputBox.getInteger("Enter and integer: ");
c= a + b;
outputBox.printLine("C = %d\n",c);
}closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}); -
I like to open several Firefox windows when I am browsing the internet. Since mi reinstall of windows XP with sp3 I installed Firefox 5.0.1. Now when I open multiple windows they kind of window in a window and I get this orange pull down menu. I can no longer close any one single window. I click the lower of the two top right X's to close the window and all the tabs in that window, but nothing happens. I also don't like the look and feel of the orange pull down menu
Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
*Don't make any changes on the Safe mode start window.
*https://support.mozilla.com/kb/Safe+Mode
In Firefox 4 and later [http://kb.mozillazine.org/Safe_mode Safe mode] disables extensions and disables hardware acceleration.
*Tools > Options > Advanced > General > Browsing: "Use hardware acceleration when available"
If disabling hardware acceleration works then check if there is an update available for your graphics display driver.
*https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes -
Constructor - open new Window - System.exit(0)
I have 1 package, with 2 java files, lets say a.java and b.java, both are compiled.
a.java and b.java are frontends.
Program starts with "a.java". Here I have a button for "b.java".
If I want to call b.java in a.java, then I call the constructor of b in a.
Then, if b is visible (and clickable), a is in background and is not clickable, until I cancel b.
I would like to do 2 things :
1) If I call b from a, it should be independant, so I still want to have access to a.
2) If I call b from a, and use System.exit(0) in b. I want, that only b exits, and not both b and a.
thanks,
AykutFor the second requirement, the only thing you can do is to have a.class and b.class run in a seperated JVM. This also satisfy the first requirement.
But for the first requirement alone, I leave to the Swing/AWT expert to answer you.
--lichu -
Close Debug Window - not exit Debug
Flash CS4 running Debug Movie and
I close the Debug Window instead of ending Debug
Flash locks up and must be restarted.
Is it me (because I automatically close the Window?)
or what?Hi:
I experienced the same behaviour on the Linux version (2.1.1.64-39)
The workarount is:
Click on the "Help" button, close the help browser, then you will be able to edit in the "Debug PL/SQL" window.
:-O -
well i had made my application with multiple windows in one form well all the window be opened through menu but the problem is that when i tried to close the windowby clicking on the close mark on the window it dont close that window well in this way if i had opened 10 or more windows they remain open and dont seem to be close by that close or hide on exit property of that windows what i conclude its a built in bug or any mistake that i had made help me out
Hi!
You must create When-Window_Closed trigger.
e.g.
if :SYSTEM.EVENT_WINDOW = 'W1'
then
Clese_Window('W1');
else
Exit_form;
end if; -
Command key activates wrong window in Mountain Lion
I've got some strange bug on my computer that has stumped every genius in the three Apple Stores I've been to--they even took it to the back to ask all the Genius' in the store, so it seems to be a nasty bug. so I figured maybe you all could help me out.
The issue is this: After I upgraded to Mountain Lion (from Snow Leopard) when I use my "command" key, it randomly activates a window other than the one in focus (on top) of the other windows. So, for example, if I'm in Safari and try to copy something (Cmd+C) but I also have Word open, it will switch to Word and copy whatever is in Word. It does this with all programs (even with Finder!), no matter what the Command function I'm trying to use. If I close the program, the strange behavior will stop for a short time and then come back with another program. When Cmd activates Finder, I have to relaunch Finder and that temporarily alleviates the problem. It does this odd behavior with an external keyboard (and the on-screen keyboard), meaning that it's a software, not hardware error.
I have taken the following actions to fix the problem:
- Reset PRAM (no change to problem)
- Using Disk Utility to repair permissions and verify disk (no change to problem)
- Created a new user on the computer (problem re-appeared after importing my backup files using MigrationAssistant)
- Created a new user on the computer and imported files without importing "Settings" but problem reappeared
- Reinstalled Mountain Lion (problem appeared after importing my backup files using MigrationAssistant)
The last Genius thought the error was due to an application corrupting some system-wide file in Mountain Lion, so we wiped my hard drive, reinstalled files, and imported my documents but not my apps. I manually installed one app at a time and had no issues for 3 months or so.
The problem "randomly" came back last week. Looking at apps that were installed recently, it shows:
- Flux (update - but Flux was on my computer for 3 months with no issues)
- Quicksand (update - but Quicksand was NOT on my computer last year when the problem started)
- VLC Media Player (this WAS on my computer last year but was NOT on my computer in the 3 months with no issue).
Thus, it seems that the culprit app was VLC. I've deleted it (using AppTrap to clear system files), but the problem still exists.
So, three questions:
1) Does anyone have any idea why this is happening, how to prevent it, or whether it might start again even if I wipe and reinstall everything?
2) I'd like to fix the problem without wiping my computer and doing a clean install of everything. Any ideas of how I could avoid doing that?
3) If I have to sacrifice VLC to solve the problem, fine, but I'd prefer not to. Any ideas as to how I could use it still?
TLDR: Command key activates wrong window in Mountain Lion; confirmed software issue; reinstall worked fine until installed VLC Media Player and problem returned; how do I fix it?
themarkofbooks
MBPro (mid 2009) on 10.8.5
Regularly (near daily) backup to TimeMachineHardware Information:
MacBook Pro (13-inch, Mid 2009)
MacBook Pro - model: MacBookPro5,5
1 2.53 GHz Intel Core 2 Duo CPU: 2 cores
8 GB RAM
Video Information:
NVIDIA GeForce 9400M - VRAM: 256 MB
Startup Items:
HP IO - Path: /Library/StartupItems/HP IO
HP Trap Monitor - Path: /Library/StartupItems/HP Trap Monitor
System Software:
OS X 10.8.5 (12F45) - Uptime: 1 day 13:6:33
Disk Information:
HGST HTS721010A9E630 disk0 : (1 TB)
disk0s1 (disk0s1) <not mounted>: 209.7 MB
Macintosh HD (disk0s2) /: 999.35 GB (65.22 GB free)
Recovery HD (disk0s3) <not mounted>: 650 MB
HL-DT-ST DVDRW GS23N
USB Information:
Apple Inc. Built-in iSight
Seagate Expansion Desk 3 TB
disk1s1 (disk1s1) <not mounted>: 314.6 MB
Time Machine (disk1s2) /Volumes/Time Machine: 1.75 TB (661.99 GB free)
Boot OS X (disk1s3) <not mounted>: 134.2 MB
Seagate (disk1s4) /Volumes/Seagate: 1.25 TB (1.25 TB free)
Apple Internal Memory Card Reader
HP Deskjet F300 series
Apple Inc. Apple Internal Keyboard / Trackpad
Apple Computer, Inc. IR Receiver
Apple Inc. BRCM2046 Hub
Apple Inc. Bluetooth USB Host Controller
FireWire Information:
Thunderbolt Information:
Kernel Extensions:
com.Cvnt.nke (2.2.0)
com.Cvnt.driver.CvntDriver (2.2.0)
Problem System Launch Daemons:
Problem System Launch Agents:
Launch Daemons:
[loaded] com.adobe.fpsaud.plist
[loaded] com.Cvnt.daemon.plist
[loaded] com.google.keystone.daemon.plist
[loaded] com.microsoft.office.licensing.helper.plist
Launch Agents:
[loaded] com.Cvnt.start.plist
[loaded] com.google.keystone.agent.plist
User Launch Agents:
[failed] com.apple.CSConfigDotMacCert-[redacted]@me.com-SharedServices.Agent.plist
User Login Items:
Flux
iTunesHelper
Bartender
Caffeine
Degrees
Dropbox
BetterSnapTool
Covenant Eyes
SkyDrive
SlimBatteryMonitor
Droplr
Battery Health
Spotdox
handyPrintDaemon
DeskConnect
SecondBar
Display Menu
Battery Time Remaining
Quicksand
Flux
CrossOver CD Helper
AppTrap
3rd Party Preference Panes:
AppTrap
Flash Player
handyPrint
Java
Perian
Internet Plug-ins:
Flash Player.plugin
FlashPlayer-10.6.plugin
googletalkbrowserplugin.plugin
iPhotoPhotocast.plugin
JavaAppletPlugin.plugin
npgtpo3dautoplugin.plugin
o1dbrowserplugin.plugin
QuickTime Plugin.plugin
SharePointBrowserPlugin.plugin
User Internet Plug-ins:
Bad Fonts:
None
Top Processes by CPU:
7% backupd
6% WindowServer
2% Finder
2% SystemUIServer
1% EtreCheck
1% hidd
1% mds
0% Microsoft Word
0% ps
0% ocspd
Top Processes by Memory:
164 MB HPScanner
139 MB WebProcess
106 MB mds
106 MB Mail
90 MB Dropbox
90 MB WindowServer
82 MB Microsoft Word
74 MB applet
74 MB Dock
66 MB DashboardClient
Virtual Memory Statistics
4.30 GB Free RAM
2.23 GB Active RAM
512 MB Inactive RAM
738 MB Wired RAM
876 MB Page-ins
0 B Page-outs -
Close browser window from applet
I have a simple applet that is called
from another application through HTML.
When the applet is done, I'd like to have
it exit and close its browser window.
How is this done? I tried System.exit(),
and that didn't do it. Neither did
destroy().The only thing I can think of is to have a function defined in JavaScript on your html page and have the applet call the method. For you to be able to do this you will have to have a MAYSCRIPT set in your applet tag.
IE:
<script language="JavaScript">
function closeWindow()
window.close();
</script>
<APPLET code="XYZApp.class" codebase="html/" align="baseline" width="200" height="200"
MAYSCRIPT>
</APPLET>
In your applet:
Make sure that you import the following.
import netscape.javascript.*;
JSObject win = JSObject.getWindow( this );
win.call( "closeWindow", null );// Calls the closeWindow() on the HTML page. -
Read sharing violation after System.exit in oracle lite DLL
I am using JRE 1.3 and successfully managed running some sql statements over jdbc.
When the java class is finished (implicit exit) then no error appears.
When I exit the code using System.exit(0) there is a windows dialog
showing a read access error AFTER the java class finished.
probably there is some cleanup the oracle DLL wants to do after the JVM exited?
Please help mailto:[email protected]
The sample code below can be used.
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @author Ivan Motsch
* @version 1.0
import java.util.*;
import java.io.*;
import java.sql.*;
public class TestOracleLite{
public TestOracleLite(){
public void start(){
Statement stm=null;
Connection conn=null;
try{
Properties p=new Properties();
p.setProperty("user","system");
p.setProperty("password","manager");
p.setProperty("DataDirectory","..\\..\\..\\TEMP\\ora4\\db");
p.setProperty("Database","ORS");
p.setProperty("IsolationLevel","Read Committed");
p.setProperty("Autocommit","Off");
p.setProperty("CursorType","Forward Only");
String ps=getPropertiesAsString(p);
Class.forName("oracle.lite.poljdbc.POLJDBCDriver");
conn=DriverManager.getConnection("jdbc:polite:whatever"+ps);
execSql(conn,
"drop table test1 cascade"
execSql(conn,
"create table test1(pk number(32),ncol number(32),scol varchar2(2000),dcol date,rcol long raw)"
conn.commit();
execSql(conn,
"insert into test1(pk,ncol,scol,dcol,rcol) values(?,?,?,?,?)",
new Object[]{new Integer(1),new Integer(1111),"Test Text",new java.sql.Date(System.currentTimeMillis()),new byte[]{0,1,2,3,4,5,6,7,8,9,10}}
conn.commit();
readSql(conn,"select * from test1");
catch(Exception e){
e.printStackTrace();
finally{
if(conn!=null){
try{
conn.close();
conn=null;
catch(Exception e){e.printStackTrace();}
private static String getPropertiesAsString(Properties p){
StringBuffer buf=new StringBuffer();
for(Iterator it=p.keySet().iterator();it.hasNext();){
String key=(String)it.next();
String val=p.getProperty(key);
buf.append(";"+key+"="+val);
return buf.toString();
public boolean execSql(Connection conn,String s){
return execSql(conn,s,(Collection)null);
public boolean execSql(Connection conn,String s,Object[] binds){
ArrayList list=new ArrayList();
if(binds!=null) list.addAll(Arrays.asList(binds));
return execSql(conn,s,list);
public boolean execSql(Connection conn,String text,Collection binds){
PreparedStatement stm=null;
try{
stm=conn.prepareStatement(text);
if(binds!=null){
int i=1;
for(Iterator it=binds.iterator();it.hasNext();){
Object o=it.next();
if(o==null){
stm.setNull(i,Types.VARCHAR);
else if(o instanceof byte[]){
stm.setBytes(i,(byte[])o);
else{
stm.setObject(i,o);
i++;
boolean b=stm.execute();
System.out.println("status: "+(b?"ok":"failed"));
return b;
catch(SQLException e){
System.out.println("status: "+"error"+" "+e);
return false;
finally{
if(stm!=null) try{stm.close();}catch(Exception e){}
public boolean readSql(Connection conn,String text){
PreparedStatement stm=null;
try{
stm=conn.prepareStatement(text);
ResultSet rs=stm.executeQuery();
ResultSetMetaData meta=rs.getMetaData();
System.out.print("col: ");
for(int i=1,n=meta.getColumnCount();i<=n;i++){
System.out.print(""+meta.getColumnName(i)+", ");
System.out.println();
while(rs.next()){
System.out.print("row: ");
for(int i=1,n=meta.getColumnCount();i<=n;i++){
System.out.print(""+rs.getObject(i)+", ");
System.out.println();
return true;
catch(SQLException e){
System.out.println("status: "+"error"+" "+e);
return false;
finally{
if(stm!=null) try{stm.close();}catch(Exception e){}
static public void main(String[] args) {
TestOracleLite t=new TestOracleLite();
t.start();
t=null;
System.exit(0);Hi
After system copy you need to do post system copy activities...
Please follow according to the installation Guide..
for example: your sld connection of your new system will be pointing to your source system. So you need to go to VA where in you can find SLD Data Supplier and change the host name, port no relavent to this i.e. your destination system...i.e.
new system.. In the same way you can follow doing the post installation activites will solve your issue.
Regards
Hari
Maybe you are looking for
-
The project could not be prepared for publishing because an error occurred. (Not enough room in heap zone / ) how can i fix this problem?
-
How do i create a icloud id to log into from my pc . my apple id doesnt work
how do i create a icloud account id from my pc
-
Ica scanner for epson expression 1600
My Epson Expression 1600 isn't working with the Lion system software. It cancels out using image capture. What should I do?
-
Hi, can anyone please guide me on how to attach a file in my phone to an email reply. (I can draft a new mail with attached file by using iFile only)
-
I need to be able to run my JSF application inside a frame from a non-JSF application. The JSF application runs fine on its own, but when I try to run it inside a frame I get a FacesContext exception: javax.servlet.jsp.JspException: Cannot find Faces