Skip navigation.
Home

plz .. run this program ..... what the problem ... why it doesnot exit after finshing the printing

import java.awt.*;

public class getfonts

{

        public static void main(String []e)

{

String []s = Toolkit.getDefaultToolkit().getFontList();

 System.out.println("Number of Fonts = " + s.length);

for(int i = 0; i<s.length; i++)
        {
            System.out.println(" Font " + i + "   : "  + s[i]);
        }

        System.out.println(" There were all fonts in your  System");

}

}

working

It is working fine and exit after printing!

By the way, write the problem in body not in the subjet and choose short and descriptive subject. Thank


Ahmed Hashim

Software Engineer

hashimblog/

dear hashim

F:\jdk\bin>java getfonts

Number of Fonts = 9

Font 0 : Dialog

Font 1 : SansSerif

Font 2 : Serif

Font 3 : Monospaced

Font 4 : Helvetica

Font 5 : TimesRoman

Font 6 : Courier

Font 7 : DialogInput

Font 8 : ZapfDingbats

There were all fonts in your System

 ^C  ... I used ctrl+c to stop the program

Me too it exits

 
Me too it exits normally

mageeb@uranium:~$ java getfonts

Number of Fonts = 5
 Font 0   : Dialog
 Font 1   : SansSerif
 Font 2   : Serif
 Font 3   : Monospaced
 Font 4   : DialogInput
 There were all fonts in your  System


Michael's eHome :: Free Coder ...

so the problem in my system no in yours

sorry for bothering you

Is it working?

Is it working?


Ahmed Hashim

Software Engineer

hashimblog/

No no you shouldn't be

  No no you shouldn't be sorry for any think.

Actually your problem is really strange. And since it is working on my machine and on Hashim's machine so I think the problem is with the environment. You may check your java version (mine is 1.5.0_6) or a problem with your operating system shell.


Michael's eHome :: Free Coder ...

the problem is that awt componenets are threads!

Al salamo 3alykom,

as i told you, awt components is a separate thread, so once reaching the end of the thread main(), you do not ending all threads in the program.

use System.exit(0) to terminate multi-threading app.