Embedded files in class?(Orignated from thre thread "Class Structure")

I have two classes which are about 1MB & 1.5MB in size. When I decompile them I get a code of only 30Kb. The classes shows swing gui components but there is no sign of swing in the byte code, forget the file produced by decompiling.
I want to know that is special is the class that gives rise to such situation.
A few things I would appreciated if repliers keep in mind:
0)The classes are 1)Unistaller of JavaEE and 2)installer of Solaris10
You may get a copy the decompiled code here:
http://javautilities.sourceforge.net/class_and_source.zip
1) Size of Byte code = 1.5MB
2) Size of code generated by decompiling = 30KB
30Kb/1.5Mb=0.02=2%=comparitively very small
3)The class shows swing components like JFrame, JButtons....
But when I search the byte code for javax.swing, or setVisible or any other set of characters generally found in a class that uses swing, I find nothing. There is no sign of swing!
4) The class extends ClassLoader, so it may be using classloader for running the classes by loadClass(byte[]b...)
5)The look and feel is JavaLookAndFeel
6)Both the Solaris10 setup and JavaEE unistaller show the same icon and more or less same type of frames.
7)I have kept them seperated from there respective environments, completely inert, and even then they work(show errors but still don't terminate)
I would be really thankful for your replies.
Thanks.
PS: This topic has originated from
http://forum.java.sun.com/thread.jspa?threadID=792867&start=0&tstart=0
you would get a better idea if you go through the first few posts from the parent thread.

My first priority is to get my question answered.I guess no matter how many multi-posts it takes
I don't know how much patience one requires.Greater than what I have.
And zodak why aren't you expressing your views in
this topic? Why did you leave the topic yesterday?Because you began to frustrate me yesterday. I can choose what topics I want to respond to, when I want to. You do know that no one is payed to help you right?
Also my name is Zadok not zodak.
Well it has been about a week I have tried getting
answers or this topic. And I am getting really weary.Then stop putting a drain on us and just do it yourself or give up.

Similar Messages

  • Why wait() is there in Object class why not in Thread class

    why wait() is there in Object class why not in Thread class .
    while we use wait() in the case of thread environment?
    If there is any situation where we use it without using threads please mention with example. or link to that example..

    839091 wrote:
    The question still remain un-answered as the answers provided are not clear. Can anybody explain why wait(), notify() methods are available in Object class and not thread?What part of the answers given did you not understand?
    Have you even tried writing any code that uses wait/notify and thought about how you'd write the same code if they existed only on Thread rather than on Object?
    Have you studied the basics of Java's multithreading?
    Do you know what a lock is?
    Do you know what the synchronized keyword does?
    Do you understand the relationship between synchronized and wait/notify?
    If you can answer yes to these questions, then the reason that wait/notify exist on Object should be obvious. So, which of the above are "no"?

  • How to refresh a JTable of a class from another thread class?

    there is an application, in server side ,there are four classes, one is a class called face class that create an JInternalFrame and on it screen a JTable, another is a class the a thread ,which accept socket from client, when it accept the client socket, it deal the data and insert into db,then notify the face class to refresh the JTable,but in the thread class I used JTable's revalidate() and updateUI() method, the JTable does not refresh ,how should i do, pls give me help ,thank you very much
    1,first file is a class that create a JInternalFrame,and on it there is a table
    public class OutFace{
    public JInternalFrame createOutFace(){
    JInternalFrame jf = new JInternalFram();
    TableModel tm = new MyTableModel();
    JTable jt = new JTable(tm);
    JScrollPane jsp = new JScrollPane();
    jsp.add(jt);
    jf.getContentPane().add(jsp);
    return jf;
    2,the second file is the main face ,there is a button,when press the button,screen the JInternalFrame. there is also a thread is beggining started .
    public class MainFace extends JFrame implements ActionListener,Runnable{
    JButton jb = new JButton("create JInternalFrame");
    jb.addActionListener(this);
    JFrame fram = new JFrame();
    public void performance(ActionEvent e){
    JInternalFrame jif = new OutFace().createOutFace(); frame.getContentPane().add(JInternalFrame,BorderLayout.CENTER);
    public static void main(String[] args){
    frame.getContentPane().add(jb,BorderLayout.NORTH);
    frame.pack();
    frame.setVisible(true);
    ServerSokct ss = new ServerSocket(10000);
    Socket skt = ss.accept()'
    new ServerThread(skt).start();
    3.the third file is a thread class, there is a serversoket ,and accept the client side data,and want to refresh the JTable of the JInternalFrame
    public class ServerThread extends Thread{
    private skt;
    public ServerThread(Sokcet skt){
    this.skt = skt;
    public void run(){
    OutputObjectStream oos = null;
    InputObjectStream ios = null;
    try{
    Boolean flag = flag;
    //here i want to refresh the JTable,how to write??
    catch(){}
    4.second is the TableModel
    public class MyTableModel{
    public TableModel createTableModel(){
    String[][] data = getData();
    TableModel tm = AbstractTableModel(
    return tm;
    public String[][] getData(){
    }

    Use the "code" formatting tags when posting code.
    Read this article on [url http://www.physci.org/codes/sscce.jsp]Creating a Simple Demo Program before posting any more code.
    Here is an example that updates a table from another thread:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=435487

  • Help! how to refresh the JTable of a class from another thread class

    there is an application, in server side ,there are two classes, one is a class called face class that screen a JTable, another is a class the a thread ,which accept socket from client, when it accept the client socket, it deal the data and insert into db,then notify the face class to refresh the JTable,but in the thread class I used JTable's revalidate() and updateUI() method, the JTable does not refresh ,how should i do, pls give me help ,thank you very much

    thank you very much !
    i tried it ,but the TableModel i used like this ,and how to change the TableModel?
    here the files of mine ,pls give me some help,thank you very much
    1,first file is a class that create a JInternalFrame,and on it there is a table
    public class OutFace{
    public JInternalFrame createOutFace(){
    JInternalFrame jf = new JInternalFram();
    TableModel tm = new MyTableModel();
    JTable jt = new JTable(tm);
    JScrollPane jsp = new JScrollPane();
    jsp.add(jt);
    jf.getContentPane().add(jsp);
    return jf;
    2,the second file is the main face ,there is a button,when press the button,screen the JInternalFrame. there is also a thread is beggining started .
    public class MainFace extends JFrame implements ActionListener,Runnable{
    JButton jb = new JButton("create JInternalFrame");
    jb.addActionListener(this);
    JFrame fram = new JFrame();
    public void performance(ActionEvent e){
    JInternalFrame jif = new OutFace().createOutFace(); frame.getContentPane().add(JInternalFrame,BorderLayout.CENTER);
    public static void main(String[] args){
    frame.getContentPane().add(jb,BorderLayout.NORTH);
    frame.pack();
    frame.setVisible(true);
    ServerSokct ss = new ServerSocket(10000);
    Socket skt = ss.accept()'
    new ServerThread(skt).start();
    3.the third file is a thread class, there is a serversoket ,and accept the client side data,and want to refresh the JTable of the JInternalFrame
    public class ServerThread extends Thread{
    private skt;
    public ServerThread(Sokcet skt){
    this.skt = skt;
    public void run(){
    OutputObjectStream oos = null;
    InputObjectStream ios = null;
    try{
    Boolean flag = flag;
    //here i want to refresh the JTable,how to write?? }
    catch(){}
    4.second is the TableModel
    public class MyTableModel{
    public TableModel createTableModel(){
    String[][] data = getData();
    TableModel tm = AbstractTableModel(
    return tm;
    public String[][] getData(){
    }

  • How to access static variable from a Thread class

    Kindly help me.......
    here's the code.....
    class Thread1 extends Thread
    int j=0;
    myClass2 mc = new myClass2();
         public void run()
              for( int a=0;a<6;a++)
                        {try
                             { Thread.sleep(5000);
                             catch(Exception e){System.out.println("Interrupted Exception");}
                             j++;
    mc.change1(i);
    } System.out.println("Thread1 executes "+j+" times");
    class Thread2 extends Thread
    int k=0;
         myClass2 mc1 = new myClass2();
         public void run()
              for( int a=0;a<6;a++)
                        {try
                             { Thread.sleep(5000);
                             catch(Exception e){System.out.println("Interrupted Exception");}
                             k++;
    mc1.change2(i);
    }System.out.println("Thread2 executes "+k+" times");
    class myClass2
    static int i=5;
    public synchronized void change1(int s)
    s=6;
    System.out.println("New value of i:"+s);
    public synchronized void change2(int s)
    s=7;
    System.out.println("New value of i:"+s);
         public static void main(String args[])
    Thread1 b1 = new Thread1();
    Thread2 b2 = new Thread2();
         b1.start();
    b2.start();
    I am unable to pass the variable i in my method call in Thread1: mc.change1(i); and similarly in Thread2:mc.change2(i);

    You can declare your i variable in myClass2 as public static and then simply call there
        mc.change1( myClass2.i ) ;

  • How to refer the parent class object from an inner class

    Hi,
    I have a class X, which contains an inner private class Y. Class X has a method getY which returns an object of class Y. Class Y has a method getParent. I want to return the object of parent class from this. The code is like this:
    public inerface IY;
    public class X {
    private class Y implements IY {
    public getParent {
    // ... return the object of parent class which created the object of this inner class
    public IY getY() {
    return new Y();
    Can somebody help me with this...

    interface IY {
    public class X {
        private class Y
            implements IY {
            private X parent;
            public Y(X x)
                parent = x;
            public X getParent()
                // ... return the object of parent class which created the object of this inner class
                return parent;
        public IY getY()
            return new Y(this);
    }Filip

  • Extract All Embedded Files in All Folders and Save Each? Copy/Paste from PDF to Word?

    I have most of what I need here, but I’m missing 2 important pieces. 
    #1)  I want to copy/paste from all PDF files in a folder and paste the copied data into a single Word file. 
    It works fine if I have ONLY Word docs in my folder.  When I have PDF files and Word files, the contents of the Word files are copied in fine, but the contents of the PDF files seem to come in as Chinese, and there is no Chinese in
    the PDF, so I have no idea where that’s coming from.
    #2)  I want to extract all embedded files (in all my Word files) and save the extracted/opened file into the folder.  Some embedded files are PDFs and some are Excel files.
    Here the code that I’m working with now.
    Sub Foo()
    Dim i As Long
    Dim MyName As String, MyPath As String
    Application.ScreenUpdating = False
    Documents.Add
    MyPath = "C:\Users\001\Desktop\Test\" ' <= change this as necessary
    MyName = Dir$(MyPath & "*.*") ' not *.* if you just want doc files
    On Error Resume Next
    Do While MyName <> ""
    If InStr(MyName, "~") = 0 Then
    Selection.InsertFile _
    FileName:="""" & MyPath & MyName & """", _
    ConfirmConversions:=False, Link:=False, _
    Attachment:=False
    Dim Myshape As InlineShape
    Dim IndexCount As Integer
    IndexCount = 1
    For Each Myshape In ActiveDocument.InlineShapes
    If Myshape.AlternativeText = PDFname Then
    ActiveDocument.InlineShapes(IndexCount).OLEFormat.Activate
    End If
    IndexCount = IndexCount + 1
    Next
    Selection.InsertBreak Type:=wdPageBreak
    End If
    On Error Resume Next
    Debug.Print MyName
    MyName = Dir ' gets the next doc file in the directory
    Loop
    End Sub
    If this has to be done using 2 Macros, that’s fine. 
    If I can do it in 1, that’s great too.
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Hi ryguy72,
    >>When I have PDF files and Word files, the contents of the Word files are copied in fine, but the contents of the PDF files seem to come in as Chinese, and there is no Chinese in the PDF, so I have no idea where that’s coming from.<<
    Based on the code, you were insert the file via the code Selection.InsertFile. I am trying to reproduce this issue however failed. I suggest that you insert the PDF file manually to see whether this issue relative to the specific file. You can insert PDF
    file via Insert->Text->Object->Text from file.
    If this issue also could reproduced manually, I would suggest that you reopen a new thread in forum to narrow down whether this issue relative to the specific PDF file or Word application.
    >> I want to extract all embedded files (in all my Word files) and save the extracted/opened file into the folder.  Some embedded files are PDFs and some are Excel files.<<
    We can save the embedded spreadsheet via Excel object model. Here is an example that check the whether the inlineshape is an embedded workbook and save it to the disk for you reference:
    If Application.ActiveDocument.InlineShapes(1).OLEFormat.ClassType = "Excel.Sheet.12" Then
    Application.ActiveDocument.InlineShapes(1).OLEFormat.DoVerb xlPrimary
    Application.ActiveDocument.InlineShapes(1).OLEFormat.Object.SaveAs "C:\workbook1.xlsx"
    Application.ActiveDocument.InlineShapes(1).OLEFormat.Object.Close
    End If
    And since the Word object model doesn't provide API to save the embedded PDF, I would suggest that you get more effective response from PDF support forum to see whether it supports automation. If yes, we can export the PDF as embedded spreadsheet like code
    absolve.
    Hope it is helpful.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Gui doesn't show when the Thread is dispatched from the main class

    Hi all,
    I've tried to write a file unzipper class that shows a small frame with 2 progress bars.
    The unzipper extends Thread class in order to make it an independant service.
    However, when I debug it and use a main function that's written within the class, it works fine, and when I run it by calling it from another main, I only see a frame where the progress window should be, but no window.
    Does anyone know what I'm doing wrong? (About the GUI, I know my unzipper isn't the most efficient one:
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipFile;
    import java.util.zip.ZipInputStream;
    * User: Administrator
    * Date: 14/10/2005
    * Time: 18:26:47
    * This is a file Unzipper;
    * It takes a zipped archive, reads it, and decompresses the files within it
    * It is a stand alone thread since the user doesn't need to wait for it or whatever;
    * It also shows a nice progress bar gui for the user to know how the decompressing works
    public class FileUnZip extends Thread{
    private ZipEntry zipEntry;
    private ZipInputStream zipInStream;
    private FileInputStream fileInputStream;
    private int sChunk=8192;//8KB buffer size for optimized i/o performance
    private byte[] buff;
    private FileOutputStream entryOutputStream;
    private BufferedOutputStream bufferedOutputStream;
    private String sourceArchiveName;
    private String targetDirectoryName;
    private String targetFileName;// a string that stores the current zipped file in the archive
    private ZipFile zipFile;
    private int zipEntriesNum;
    private int readsNumber;//for knowing how many i/o approaches are required
    //for progress bar gui:
    private JProgressBar overAllProgBar;
    private JProgressBar currentFileProgBar;
    private JPanel progPanel;
    private JLabel overAllLabel;
    private JLabel currentFileLabel;
    private int currFileValue=0;
    private int currEntryValue=0;
    private JFrame progFrm;
    //constructor that produces the output in the same directory as source
    public FileUnZip(String sourceArchiveN) {
    sourceArchiveName = sourceArchiveN;
    targetDirectoryName=sourceArchiveName.substring(0,
    sourceArchiveName.length()-4);//trim ".zip"
    // for clean directory name
    File dir=new File (targetDirectoryName);
    dir.mkdir();
    this.start();
    //constructor that produces the output in the given targetDir... directory
    public FileUnZip(String sourceArchiveN, String targetFileN) {
    sourceArchiveName = sourceArchiveN;
    targetDirectoryName = targetFileN.substring(0,targetFileN.length()-4);
    // for clean directory name
    File dir=new File (targetDirectoryName);
    dir.mkdir();
    this.start();
    public void initGui(){
    JFrame.setDefaultLookAndFeelDecorated(true);
    progFrm = new JFrame("Extracting " + sourceArchiveName);
    progPanel = new JPanel(new GridLayout(2,2));
    overAllLabel = new JLabel("<html><body><font size=4 color=red>Over All"+
    "</color></size><font><body><html>");
    progPanel.add(overAllLabel);
    overAllProgBar = new JProgressBar(currEntryValue, zipEntriesNum);
    overAllProgBar.setStringPainted(true);
    progPanel.add(overAllProgBar);
    currentFileProgBar = new JProgressBar(currFileValue, sChunk);
    currentFileProgBar.setStringPainted(true);
    currentFileLabel = new JLabel("<html><body>" +
    "<font size=4 color=red>Current file"+
    "</color></size><font><body><html>") ;
    progPanel.add(currentFileLabel);
    progPanel.add(currentFileProgBar);
    progFrm.getContentPane().add(progPanel);
    progFrm.pack();
    progFrm.setResizable(false);
    progFrm.setVisible(true);
    public void initStreams(){
    try {
    zipFile = new ZipFile(sourceArchiveName);
    zipEntriesNum=zipFile.size();// get entries number from the archive,
    //used for displaying the overall progressbar
    } catch (IOException e) {
    System.out.println("can't initiate zip file");
    if (zipFile!=null) {
    try {
    zipFile.close();
    } catch (IOException e) {
    System.out.println("zip file never initiated");
    try {
    fileInputStream = new FileInputStream(sourceArchiveName);
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    zipInStream = new ZipInputStream(new BufferedInputStream(
    fileInputStream));
    buff=new byte[sChunk];
    public void start(){
    initStreams();
    initGui();
    run();
    public void run(){
    File outputFile;
    int succeededReading=0;
    try {
    while((zipEntry = zipInStream.getNextEntry())!=null){
    overAllProgBar.setValue(++currEntryValue);
    readsNumber=(int)zipEntry.getSize()/sChunk;
    currentFileProgBar.setMaximum(readsNumber);
    targetFileName=targetDirectoryName +
    File.separator + zipEntry.getName();
    outputFile=new File(targetFileName);
    System.out.println("outputFile.getAbsolutePath() = "
    + outputFile.getAbsolutePath());
    if(!outputFile.exists()){
    outputFile.createNewFile();
    entryOutputStream=new FileOutputStream(outputFile);
    bufferedOutputStream = new BufferedOutputStream(
    entryOutputStream, sChunk);
    while((succeededReading=zipInStream.read(
    buff,0,sChunk))!=-1){ //extract single entry
    bufferedOutputStream.write(buff,0,succeededReading);
    currentFileProgBar.setValue(++currFileValue);
    bufferedOutputStream.flush();
    bufferedOutputStream.close();
    entryOutputStream.flush();
    currFileValue = 0;
    } catch (IOException e) {
    e.printStackTrace();
    finalize();
    public void closeStreams(){
    try {
    zipInStream.close();
    } catch (IOException e) {
    e.printStackTrace();
    try {
    fileInputStream.close();
    } catch (IOException e) {
    e.printStackTrace();
    if (entryOutputStream!=null) {
    try {
    entryOutputStream.flush();
    entryOutputStream.close();
    } catch (IOException e) {
    System.out.println("entry stream never opened");
    if(bufferedOutputStream!=null){
    try {
    bufferedOutputStream.flush();
    bufferedOutputStream.close();
    } catch (IOException e) {
    e.printStackTrace();
    public void finalize(){
    try {
    super.finalize();
    } catch (Throwable throwable) {
    throwable.printStackTrace();
    progFrm.dispose();
    closeStreams();
    endTask();
    private void endTask(){
    //play a sound when task is complete
    java.awt.Toolkit.getDefaultToolkit().beep();
    }

    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipFile;
    import java.util.zip.ZipInputStream;
    * User: Administrator
    * Date: 14/10/2005
    * Time: 18:26:47
    * This is a file Unzipper;
    * It takes a zipped archive, reads it, and decompresses the files within it
    * It is a stand alone thread since the user doesn't need to wait for it or whatever;
    * It also shows a nice progress bar gui for the user to know how the decompressing works
    public class FileUnZip extends Thread{
        private ZipEntry zipEntry;
        private ZipInputStream zipInStream;
        private FileInputStream fileInputStream;
        private int sChunk=8192;//8KB buffer size for optimized i/o performance
        private byte[] buff;
        private FileOutputStream entryOutputStream;
        private BufferedOutputStream bufferedOutputStream;
        private String sourceArchiveName;
        private String targetDirectoryName;
        private String targetFileName;// a string that stores the current zipped file in the archive
        private ZipFile zipFile;
        private int zipEntriesNum;
        private int readsNumber;//for knowing how many i/o approaches are required
    //for progress bar gui:
        private JProgressBar overAllProgBar;
        private JProgressBar currentFileProgBar;
        private JPanel progPanel;
        private JLabel overAllLabel;
        private JLabel currentFileLabel;
        private int currFileValue=0;
        private int currEntryValue=0;
        private JFrame progFrm;
    //constructor that produces the output in the same directory as source
        public FileUnZip(String sourceArchiveN) {
            sourceArchiveName = sourceArchiveN;
            targetDirectoryName=sourceArchiveName.substring(0,
                    sourceArchiveName.length()-4);//trim ".zip"
    // for clean directory name
            File dir=new File(targetDirectoryName);
            dir.mkdir();
            this.start();
    //constructor that produces the output in the given targetDir... directory
        public FileUnZip(String sourceArchiveN, String targetFileN) {
            sourceArchiveName = sourceArchiveN;
            targetDirectoryName = targetFileN.substring(0,targetFileN.length()-4);
    // for clean directory name
            File dir=new File(targetDirectoryName);
            dir.mkdir();
            this.start();
        public void initGui(){
            JFrame.setDefaultLookAndFeelDecorated(true);
            progFrm = new JFrame("Extracting " + sourceArchiveName);
            progPanel = new JPanel(new GridLayout(2,2));
            overAllLabel = new JLabel("<html><body><font size=4 color=red>Over All"+
                    "</color></size><font><body><html>");
            progPanel.add(overAllLabel);
            overAllProgBar = new JProgressBar(currEntryValue, zipEntriesNum);
            overAllProgBar.setStringPainted(true);
            progPanel.add(overAllProgBar);
            currentFileProgBar = new JProgressBar(currFileValue, sChunk);
            currentFileProgBar.setStringPainted(true);
            currentFileLabel = new JLabel("<html><body>" +
                    "<font size=4 color=red>Current file"+
                    "</color></size><font><body><html>") ;
            progPanel.add(currentFileLabel);
            progPanel.add(currentFileProgBar);
            progFrm.getContentPane().add(progPanel);
            progFrm.pack();
            progFrm.setResizable(false);
            progFrm.setVisible(true);
        public void initStreams(){
            try {
                zipFile = new ZipFile(sourceArchiveName);
                zipEntriesNum=zipFile.size();// get entries number from the archive,
    //used for displaying the overall progressbar
            } catch (IOException e) {
                System.out.println("can't initiate zip file");
            if (zipFile!=null) {
                try {
                    zipFile.close();
                } catch (IOException e) {
                    System.out.println("zip file never initiated");
            try {
                fileInputStream = new FileInputStream(sourceArchiveName);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            zipInStream = new ZipInputStream(new BufferedInputStream(
                    fileInputStream));
            buff=new byte[sChunk];
        public void start(){
            initStreams();
            initGui();
            run();
        public void run(){
            File outputFile;
            int succeededReading=0;
            try {
                while((zipEntry = zipInStream.getNextEntry())!=null){
                    overAllProgBar.setValue(++currEntryValue);
                    readsNumber=(int)zipEntry.getSize()/sChunk;
                    currentFileProgBar.setMaximum(readsNumber);
                    targetFileName=targetDirectoryName +
                            File.separator + zipEntry.getName();
                    outputFile=new File(targetFileName);
                    System.out.println("outputFile.getAbsolutePath() = "
                            + outputFile.getAbsolutePath());
                    if(!outputFile.exists()){
                        outputFile.createNewFile();
                    entryOutputStream=new FileOutputStream(outputFile);
                    bufferedOutputStream = new BufferedOutputStream(
                            entryOutputStream, sChunk);
                    while((succeededReading=zipInStream.read(
                            buff,0,sChunk))!=-1){ //extract single entry
                        bufferedOutputStream.write(buff,0,succeededReading);
                        currentFileProgBar.setValue(++currFileValue);
                    bufferedOutputStream.flush();
                    bufferedOutputStream.close();
                    entryOutputStream.flush();
                    currFileValue = 0;
            } catch (IOException e) {
                e.printStackTrace();
            finalize();
        public void closeStreams(){
            try {
                zipInStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            try {
                fileInputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            if (entryOutputStream!=null) {
                try {
                    entryOutputStream.flush();
                    entryOutputStream.close();
                } catch (IOException e) {
                    System.out.println("entry stream never opened");
            if(bufferedOutputStream!=null){
                try {
                    bufferedOutputStream.flush();
                    bufferedOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
        public void finalize(){
            try {
                super.finalize();
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            progFrm.dispose();
            closeStreams();
            endTask();
        private void endTask(){
    //play a sound when task is complete
            java.awt.Toolkit.getDefaultToolkit().beep();
    }

  • How to read from and write into the same file from multiple threads?

    I need to read from and write into a same file multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

    Assuming you are using RandomAccessFile, you can use the locking functionality in the Java NIO library to lock sections of a file that you are reading/writing from each thread (or process).
    If you can't use NIO, and all your threads are in the same application, you can create your own in-process locking mechanism that each thread uses prior to accessing the file. That would take some development, and the OS already has the capability, so using NIO is the best way to go if you can use JDK 1.4 or higher.
    - K
    I need to read from and write into a same file
    multiple threads.
    How can we do that without any data contamination.
    Can u please provide coding for this type of task.
    Thanks in advance.

  • Access jar file from in-memory classes...

    I have some classes that I compile to memory and everything works fine until one class that must access some external jar files. I have been unable to access those jar files from disk after trying every suggestion using URLClassLoader. I even tried someone's example to hack the SystemClassLoader which properly adds the jar file paths, but still they can't be seen. The only way it works is if I put the files in the jdk/jre/lib/ext directory. Then everything works fine. There must be a way to load the jar files in memory as well as the class files so they can be accessible. Has anyone done anything like this? Is it possible? Even though the class files are in memory, why would the jar files not be seen even when they are added to the same URLClassLoader's URL's. Thanks.

    Sorry that wasn't clear. What I mean is that the classes are compiled to byte code directly to memory and no physical .class file is created. Yes, I'm using my own ClassLoader that extends URLClassLoader and I'm setting the parent to ClassLoader.getSystemClassLoader(). I also should mention that I'm doing this inside a Netbeans module that is part of a Netbeans Platform application. I don't know why that should matter though, since I'm trying to do everything in memory without creating the physical files. Thanks.

  • Target movieclip from an AS3 class file - remove/add Child

    Halo.
    I have a very simple question  (for those who use external class files).
    Assuming that I have a MovieClip manually added to Stage and I want to access it from inside my class definiton.
    So the code would be:
    MovieClip(root).MyMovieClip
    But I can't figure out how to use remove/add Child in that kind of situation.
    I will appreciate any advice.
    Thanks

    if you can reference using that, you can remove using:
    MovieClip(root).MyMovieClip.parent.removeChild(MovieClip(root).MyMovieClip);
    and you can add to any displayobjectcontainer.

  • How to use methods from a JAR file inside my springcontext (Oracle fusion 12c) class file?

    Dear Friends,
    I have a jar file, which has executed classes and methods in it. I want to make use of these methods inside my springcontext piece of code.
    Can someone please share an example  of how to write spingcontext code which is accessing classes/methods from  JAR files along with the any setup?
    Thanks,

    I have found the answer... as described in:
    http://java.sun.com/javase/6/docs/technotes/guides/lang/resources.html
    the problem was that the properties are loaded with the getResource & getResourceAsStream methods and I didn't know that one. I thought that is was loaded through findClass because I saw the property files trying to be loaded through findClass.
    The truth is that it tries to load with the getRessources methods and if it fails tries with the findClass/loadClass.
    To Fix the problem, I have simply overriden the getRessourceAsStream to do my magic and that was it.
    Thanks

  • Accessing object of the main class from the thread

    Hi, I'm having problem accessing object of the main class from the thread. I have only one Thread and I'm calling log.append() from the Thread. Object log is defined and inicialized in the main class like this:
    public Text log;  // Text is SWT component
    log = new Text(...);Here is a Thread code:
    ...while((line = br.readLine())!=null) {
         try {
              log.append(line + "\r\n");
         } catch (SWTException swte) {
              ErrorMsg("SWT error: "+swte.getMessage());
    }Error is: org.eclipse.swt.SWTException: Invalid thread access
    When I replace log.append(...) with System.out.println(..) it works just fine, so my question is do the log.append(..) the right way.

    This is NOT a Java problem but a SWT specific issue.
    It is listed on the SWT FAQ page http://www.eclipse.org/swt/faq.php#uithread
    For more help with this you need to ask your question on a SWT specific forum, there is not a thing in these forums. This advice isn't just about SWT by the way but for all specific API exceptions/problems. You should take those questions to the forum or mailing list for that API. This forum is for general problems and exceptions arising from using the "core" Java libraries.

  • "Safe" delete of Thread class from a Vector

    I need to be able to delete a thread class object from a vector.
    1) Is it safe to do so immedately after calling xyz.stop() ?
    2) If so, does Java clean all the thread stuff up automatically ?
    3) If not, is there something else I should do to clean up?

    The stop method of class Thread is deprecated, however it's still possible to stop this thread. A thread's memory should become available for garbage collection the moment it is no longer executing, and it is no longer being reffered to.
    To stop your thread, you need to set a boolean flag that is available to it to false:
    Thread myThread = new Thread()
         public boolean stopRunning = false;
         public boolean threadComplete = false;
         public void run()
              while(!stopRunning)
                   doSomething();
              threadComplete = true;
    }If you are doing something involving blocking I/O inside your thread, you're going to need to interrupt the thread after setting this public flag to true in order to get it to stop executing.
    Then you can simply remove it's refference from that Vector, and it will become elligable for Garbage collection the moment it becomes inactive.
    -Jason Thomas.

  • Create Class objects from an Array of File Objects

    Hi There,
    I'm having extreme difficulty in trying to convert an array of file objects to Class objects. My problem is as follows: I'm using Jfilechooser to select a directory and get an array of files of which are all .class files. I want to create Class objects from these .class files. Therefore, i can extract all the constructor, method and field information. I eventually want this class information to display in a JTree. Very similar to the explorer used in Netbeans. I've already created some code below, but it seems to be throwing a NoSuchMethodError exception. Can anyone please help??
    Thanks in advance,
    Vikash
    /* the following is the class im using */
    class FileClassLoader extends ClassLoader {
    private File file;
    public FileClassLoader (File ff) {
    this.file = ff;
    protected synchronized Class loadClass() throws ClassNotFoundException {
    Class c = null;
    try {
    // Get size of class file
    int size = (int)file.length();
    // Reserve space to read
    byte buff[] = new byte[size];
    // Get stream to read from
    FileInputStream fis = new FileInputStream(file);
    DataInputStream dis = new DataInputStream (fis);
    // Read in data
    dis.readFully (buff);
    // close stream
    dis.close();
    // get class name and remove ".class"
    String classname = null;
    String filename = file.getName();
    int i = filename.lastIndexOf('.');
    if(i>0 && i<filename.length()-1) {
    classname = filename.substring(0,i);
    // create class object from bytes
    c = defineClass (classname, buff, 0, buff.length);
    resolveClass (c);
    } catch (java.io.IOException e) {
    e.printStackTrace();
    return c;
    } // end of method loadClass
    } // end of class FileClassLoader
    /* The above class is used in the following button action in my gui */
    /* At the moment im trying to output the data to standard output */
    private void SelectPackage_but2ActionPerformed(java.awt.event.ActionEvent evt) {
    final JFileChooser f = new JFileChooser();
    f.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int rVal = f.showOpenDialog(Remedy.this);
    // selects directory
    File dir = f.getSelectedFile();
    // gets a list of files within the directory
    File[] allfiles = dir.listFiles();
    // for loop to filter out all the .class files
    for (int k=0; k < allfiles.length; k++) {
    if (allfiles[k].getName().endsWith(".class")) {
    try {
    System.out.println("File name: " + allfiles[k].getName()); // used for debugging
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    Class cl = loader.loadClass();
    //Class cl = null;
    Class[] interfaces = cl.getInterfaces();
    java.lang.reflect.Method[] methods = cl.getDeclaredMethods();
    java.lang.reflect.Field[] fields = cl.getDeclaredFields();
    System.out.println("Class Name: " + cl.getName());
    //print out methods
    for (int m=0; m < methods.length; m++) {
    System.out.println("Method: " + methods[m].getName());
    // print out fields
    for (int fld=0; fld < fields.length; fld++) {
    System.out.println("Field: " + fields[fld].getName());
    } catch (Exception e) {
    e.printStackTrace();
    } // end of if loop
    } // end of for loop
    packageName2.setText(dir.getPath());
    }

    It's throwing the exeption on the line:
    FileClassLoader loader = new FileClassLoader(allfiles[k]);
    I'm sure its something to do with the extended class i've created. but i cant seem to figure it out..
    Thanks if you can figure it out

Maybe you are looking for

  • Can I get all my songs and playlist to a Flash dirve to play in the car now the large iPod is no more?

    Hello, so I have read a few discussions on transferring songs/playlist to a flash drive. But what I am looking for is can I replace my iPod classic in my car with a flash drive? So I have all my songs and playlist just like the iPod. And how do I do

  • Scanning causes error when opening PDF

    Every time I scan or print with my HP Officejet 5610v, I can then no longer open a pdf by finding a file in the finder. When I try I get the following error: The document "iPhone intro.pdf" could not be opened. Acrobat cannot open files in the "Adobe

  • I have an error msg:  Warning!! iOS Crash Report

    I just got this error msg. Warning!!  iOS Crash Report.   Due to a third party application in your phone, iOS is crashed.  Contact Support for an Immediate Fix. There is a 1-800 number noted.  Is this legit or this this a virus?  We have tried shutti

  • How to install Excell client using Silent Installation

    Hi, We are planning to do the 'client install' using silent installation. I followed the BPC 7.5 installation giude but it just gives the option to do the both ADMIN and EXCEL client installation. For example:bpcclient75.exe /s /zu201Cc:\test&c:\inst

  • Help Syncing iPod

    My old computer crashed, and I can't even turn it on now due to a virus.  I have a new computer, and have downloaded new songs into the new computers iTunes library, but it won't let me sync the ipod to the new computer.  How do I get the new compute