Big .jar File - need a loading/info screen

Hi,
my problem is that my midlet takes too long to run, because the jar file is quite big (1,5mb) and has a lot of txt files (around 6.500).
Now you might wonder why i have a lot of files in my jar.
I have a book which is devided into verse. The user search for a particular verse. It takes too long if I have to open a big file and then display a verse, so i made a txt file for each verse which is faster, because the midlet just has to open the little file which contains the verse.
Because of the amount of txt files it takes some time until my midlet starts.
I wanted to ask where there is way to at least tell the user that my midlet is going to start, but that it will take a little bit.
I cannot put this file into the same jar, since loading the jar takes the time.
Is there a way to make a loading info and then open my jar file, which contains the real midlet?
My midlet takes around 45 seconds to open( on my mobile phone), and until then there is no sign whether the midlet is going to start or not. If I do not inform the User, he might think that my midlet won't work and he would press other buttons (like the cancel button).

I think there is no way because :
- if you put it into your jar, it has to be loaded ...
- if you put it outside your jar (JSR 75), the class code has to be executed and so your jar has to be loaded
- everything you will try to execute an application that lauch this one would be weird stuff ...
- note that it sould work on an emulator, but most phones have a jar size limit that is only a few hundreds ko
Regards.

Similar Messages

  • Required the details of jar files which is loaded in the database

    Hi
    We are having a 10g database which is running under Solaris machine. There are lot of .jar files which are loaded into the database. I would like to know how to find those .jar file details atlease the name of the files which are loaded in the database. Is there any view for this.
    I couldnt find anything from the Java option in TOAD
    Please provide a solution.
    Thanks
    SHIYAS M

    From 11g onwards, you have
    SQL> select * from v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    PL/SQL Release 11.2.0.3.0 - Production
    CORE 11.2.0.3.0 Production
    TNS for Linux: Version 11.2.0.3.0 - Production
    NLSRTL Version 11.2.0.3.0 - Production
    SQL> desc javajar$
    Name Null? Type
    NAME NOT NULL VARCHAR2(30)
    OWNER# NOT NULL NUMBER
    PATH VARCHAR2(4000)
    CONTENTS BLOB
    SQL> desc javajarobjects$
    Name Null? Type
    JARNAME NOT NULL VARCHAR2(30)
    OWNER# NOT NULL NUMBER
    OBJNAME NOT NULL VARCHAR2(40)
    NAMESPACE NOT NULL NUMBER

  • List of .jar file need to add in web application by using eclipse europa?

    hi
    what are the list of .jar file need to be added in web application which use the ide of Eclipse Europa?

    Depends on the application requirements. For a basic JSP/Servlet application just integrate Tomcat in Eclipse and assign it as application server to your web project, then you don't need to add anything. If you for example need JSF, then you should add its JAR's to the classpath of the web project, which is by default /WEB-INF/lib.

  • Unsigned jacob.jar file causing forms loading slow

    Dear All,
    Oracle version : 10.1.2.0.2
    OS: Windows 2003
    Client IE version : IE 8
    JRE version : JRE 1.6 update 21
    JRE security setting : Mixed code (sandboxed vs. trusted) security verification - Disabled
    We are getting the unsigned jar file error for jacob.jar, but it is running fine in many other places and giving unsigned jar file error for other jar files.
    Loaded image: jar:http://192.168.100.88:7778/forms/java/frmall.jar!/oracle/forms/icons/frame.gif
    Trace level set to 5: all ... completed.
    cache: Reading Signers from 0 http://192.168.100.88:7778/forms/java/jacob.jar | C:\Users\samm.AGS-STORE-005\AppData\LocalLow\Sun\Java\Deployment\cache\6.0\48\dc408b0-3aabe349.idx
    network: No certificate info for unsigned JAR file: http://192.168.100.88:7778/forms/java/jacob.jar
    network: No certificate info for unsigned JAR file: http://192.168.100.88:7778/forms/java/jacob.jar
    network: Connecting http://192.168.100.88:7778/forms/lservlet;jsessionid=c0a8645830d6885b096494a44406bb10e869f532355e.e38LbhmPbxyKci0La3qPa3iNa38Re6fznA5Pp7ftolbGmkTy with proxy=DIRECT
    I have seen sites to sign the jar files, but is it possible to overcome this error without signing. Since this error is taking 10-20 secs more to load the form.
    Please help.
    Thanks and Regards,
    Anand.

    HI,
    You need to sign both frmwebutil.jar and jacob.jar first the clear JAR cache ion end-user computer,so that new signed JAR files are downloaded to end-user machines..

  • Add a jar file to Java load path at run time

    Hi
    I loaded my file successfully , but when I tried to use the driver to connect to the DB , I get
    java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
    Here is my class
    import java.net.URL;
    import java.io.IOException;
    import java.net.URLClassLoader;
    import java.net.MalformedURLException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.io.*;
    public class JarFileLoader1 extends URLClassLoader
    public JarFileLoader1 (URL[] urls)
    super (urls);
    public void addFile (String path) throws MalformedURLException
    String urlPath = "jar:file://" + path + "!/";
    addURL (new URL (urlPath));
    public static void main (String args[])
    try
    File f = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc.jar");
    System.out.println("%%%% " + f.exists());
    File f1 = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc_license_cu.jar");
    System.out.println("%%%% " + f1.exists());
    File f2 = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc4.jar");
    System.out.println("%%%% " + f2.exists());
    URL urls [] = {};
    JarFileLoader1 cl = new JarFileLoader1 (urls);
    cl.addFile ("E:\\db2_v9_5 FP5_drivers\\db2jcc.jar");
    cl.addFile ("E:\\db2_v9_5 FP5_drivers\\db2jcc_license_cu.jar");
    cl.addFile ("E:\\db2_v9_5 FP5_drivers\\db2jcc4.jar");
    URL url = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc.jar").toURL();
    URLClassLoader clazzLoader = new URLClassLoader(new URL[]url);
    Class clazz = clazzLoader.loadClass("com.ibm.db2.jcc.DB2Driver");
    System.out.println ("Success! --> " + clazz.newInstance().toString());
    String connectString = "jdbc:db2://dummy:34000/dev1";
    System.out.println("BEFORE CONNECTION");
    Connection conn =
    DriverManager.getConnection(connectString,"mario","123123");
    System.out.println("after CONNECTION");
    System.out.println("Driver Version - " + conn.getMetaData().getDriverVersion() + "
    catch (Exception ex)
    System.out.println ("In Exception Block -- Failed.");
    ex.printStackTrace (System.out);
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Here are the logging messages
    %%%% true
    %%%% true
    %%%% true
    Success! --> com.ibm.db2.jcc.DB2Driver@24442444
    BEFORE CONNECTION
    In Exception Block -- Failed.
    java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:186)
    at com.tdbfg.tdsecurities.kasper.admin.aboutkasper.JarFileLoader1.main(JarFileLoader1.java:61)

    kasper123 wrote:
    Hi
    I loaded my file successfully , but when I tried to use the driver to connect to the DB , I get
    java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
    Here is my class
    import java.net.URL;
    import java.io.IOException;
    import java.net.URLClassLoader;
    import java.net.MalformedURLException;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.io.*;
    public class JarFileLoader1 extends URLClassLoader
    public JarFileLoader1 (URL[] urls)
    super (urls);
    public void addFile (String path) throws MalformedURLException
    String urlPath = "jar:file://" + path + "!/";
    addURL (new URL (urlPath));
    public static void main (String args[])
    try
    File f = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc.jar");
    System.out.println("%%%% " + f.exists());
    File f1 = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc_license_cu.jar");
    System.out.println("%%%% " + f1.exists());
    File f2 = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc4.jar");
    System.out.println("%%%% " + f2.exists());
    URL urls [] = {};
    JarFileLoader1 cl = new JarFileLoader1 (urls);
    cl.addFile ("E:\\db2_v9_5 FP5_drivers\\db2jcc.jar");
    cl.addFile ("E:\\db2_v9_5 FP5_drivers\\db2jcc_license_cu.jar");
    cl.addFile ("E:\\db2_v9_5 FP5_drivers\\db2jcc4.jar");
    URL url = new File("E:\\db2_v9_5 FP5_drivers\\db2jcc.jar").toURL();
    URLClassLoader clazzLoader = new URLClassLoader(new URL[]{url});
    Class clazz = clazzLoader.loadClass("com.ibm.db2.jcc.DB2Driver");
    System.out.println ("Success! --> " + clazz.newInstance().toString());
    String connectString = "jdbc:db2://dummy:34000/dev1";
    System.out.println("BEFORE CONNECTION");
    Connection conn =
    DriverManager.getConnection(connectString,"mario","123123");
    System.out.println("after CONNECTION");
    System.out.println("Driver Version - " + conn.getMetaData().getDriverVersion() + " ");
    catch (Exception ex)
    System.out.println ("In Exception Block -- Failed.");
    ex.printStackTrace (System.out);
    }================================================
    ====================================================
    Here are the logging messages
    %%%% true
    %%%% true
    %%%% true
    Success! --> com.ibm.db2.jcc.DB2Driver@24442444
    BEFORE CONNECTION
    In Exception Block -- Failed.
    java.sql.SQLException: No suitable driver
    at java.sql.DriverManager.getConnection(DriverManager.java:582)
    at java.sql.DriverManager.getConnection(DriverManager.java:186)
    at com.tdbfg.tdsecurities.kasper.admin.aboutkasper.JarFileLoader1.main(JarFileLoader1.java:61)
    For debugging purposes you could use [DriverManager.getDrivers()|http://download.oracle.com/javase/6/docs/api/java/sql/DriverManager.html#getDrivers%28%29] to get an enumeration of all drivers
    and then output their names.
    Maybe, with the classloader malarkey you are doing
    you need to use [DriverManager.registerDriver(Driver driver)|http://download.oracle.com/javase/6/docs/api/java/sql/DriverManager.html#registerDriver%28java.sql.Driver%29]

  • JAR files needed ?

    I am trying to create a Dynamic Web Project in Eclipse exactly as Portal Project in Workshop, I am trying to find what are the JAR files we needed,
    Can any one point me to any resources where i can look into it,
    Thanks
    JD

    Hi,
    Use IBM class loader plug-in for Eclipse to find the required jar files by specifying the package name or class name. This will help you to avoid including files, which are not required.
    Regards,
    Bhavani Prasad

  • The jar files needed to use MQ Sonique driver

    Hi,
    I am using the Sun JMS adapter
    and the driver  is Sonique MQ Series
    can I know what jar files are needed to make the set up
    in to the XI server?
    Thanks & Regards
    Ranjit

    Hi,
    Add sonic_Client.jar.
    Regards,
    sudheer.

  • Jar files need for Custom connector API app

    hi all,
    I am doing an application regarding "Custom connector API", for doing the application I need "jdom,rome-0.6" jar files. kindly send these jar files it will be helpful to me. To do such custom connector API application any plugins must be added to  it, if so please let me know???
    thanks in advance,
    Aravind.

    Hi,
    You can find the jdom.jar file from the plugins/com.sap.km.rfwirad_7.1.5/lib/jdom.jar.
    If you add classlocator to your studio you can find the required jar file for your imported classes very easily. To add the classlocator to your studio go to the below blog
    Using JAR Class Finder
    Regards
    Suresh

  • Does driver jar file needs to be extracted before giving java command?

    I wrote a JDBC program, where it will pull the data from Sybase and Push into Oracle. That program is working fine in Eclipse IDE. But when i tried to make it make it work from the command program, by giving javac and java commands..., it didnt work.
    Finally i realised that, it is working when i extract the driver jar files (sybase and Oracle, ojdbc.jar and jconn3.jar ) using jar xvf utility.
    Do we need to do that? or is there any smart way that we can just mention the drivers path and make it work?
    For your information, i set the CLASSPATH and JDBC_HOME to the driver location.
    Please help me out
    Thank You
    Viswa

    Hi Balu,
    Could you please check this?
    umi-c005-m3:~/TestRem2CCM/SampleProgram 179> ls -l
    total 928
    -rwxrwxrwx 1 500 500 465869 Sep 30 2005 jconn3.jar
    drwxrwxrwx 2 500 500 4096 Jun 5 11:45 psae
    umi-c005-m3:~/TestRem2CCM/SampleProgram 180> ls -l psae/
    total 96
    -rwxrwxrwx 1 ramavi11 500 3251 Jun 5 11:27 DataModel.class
    -rwxrwxrwx 1 500 500 3564 Jun 5 11:26 DataModel.java~
    -rwxrwxrwx 1 500 500 3564 Jun 5 11:27 DataModel.java
    -rwxrwxrwx 1 ramavi11 500 8358 Jun 5 11:27 DataTransfer.class
    -rw-rw-rw- 1 500 500 11126 Jun 5 11:25 DataTransfer.java~
    -rwxrwxrwx 1 500 500 11127 Jun 5 11:45 DataTransfer.java
    umi-c005-m3:~/TestRem2CCM/SampleProgram 181> java -cp . psae/DataTransfer
    Before Try
    Inside Try
    *********Sybase Connection Failed*************
    java.lang.ClassNotFoundException: com.sybase.jdbc3.jdbc.SybDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at psae.DataTransfer.getSybaseDataList(DataTransfer.java:191)
    at psae.DataTransfer.main(DataTransfer.java:19)
    Data NOT available from MMS query
    umi-c005-m3:~/TestRem2CCM/SampleProgram 182> java -cp . psae.DataTransfer
    Before Try
    Inside Try
    *********Sybase Connection Failed*************
    java.lang.ClassNotFoundException: com.sybase.jdbc3.jdbc.SybDriver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at psae.DataTransfer.getSybaseDataList(DataTransfer.java:191)
    at psae.DataTransfer.main(DataTransfer.java:19)
    Data NOT available from MMS query
    umi-c005-m3:~/TestRem2CCM/SampleProgram 183>

  • What are the jar files needed for HTMMLB?

    Hi,
    I have imported a HTMLB comp par file into my NWDS.
    it is showing me some errors like com.sapportals.htmlb cannot be resolved...what may be the prob...do i need to import any jar files regarding this.
    Plz help..
    Thanks,
    Viswes

    Hi,
    Please see this helpful link
    New Reference for Portal APIs
    Ramganesan Karuppaiyah

  • Sql loader ?.  CSV file need 2 load to multi tbls

    I have a CSV file i.e.
    3 columns on file (qy_type_cd,cd_description,tablename)
    example data:
    PAST,Past Program Quantity,MASTER_QY
    FUT_PEACE,Future Peace Program Quantity,MASTER_QY
    TM_PHAS_USE,Time Phased Users Quantity,ADDITIVE_QY
    MISTR_RPR,MISTR Repair Quantity,USAGE_QY
    I need to load to 3 tables. Tables have two columns (qy_type,description).
    How can i read the tablename from csv file and load the qy_type_cd and cd_description INTO a table
    something like this. but I dont know the syntax
    into table api_mstr_qy
    fields terminated by ","
    when tablename ='MASTER_QY'
    (qy_type,description,tablename)

    First you need to create a directory that corresponds to where the csv file is located
    create directory mydir as 'c:\loaddata\'
    Then you need to define the metadata for the
    external table:
    CREATE TABLE myExternal (
    qy_type_cd varchar2,
    cd_description varchar2,
    tablename varchar2
    ORGANIZATION EXTERNAL
    (DEFAULT DIRECTORY mydir
    ACCESS PARAMETERS
    (RECORDS DELIMITED BY NEWLINE
    BADFILE 'bad_external'
    LOGDILE 'log_external'
    FIELDS TERMINATED BY ','
    qy_type_cd char,
    cd_description char,
    tablename char
    LOCATION (mycsv.csv))
    PARALLEL 1 --PUT 2 or the amount of clustered servers you want to use for the process
    REJECT LIMIT 1;
    Now you are able to run selects on this table
    ie: select * from myExternal will produce:
    PAST,Past Program Quantity,MASTER_QY
    FUT_PEACE,Future Peace Program Quantity,MASTER_QY
    TM_PHAS_USE,Time Phased Users Quantity,ADDITIVE_QY
    MISTR_RPR,MISTR Repair Quantity,USAGE_QY
    So here is where you use the conditional INSERT:
    INSERT
    WHEN tablename ='MASTER_QY' THEN
         INTO api_mstr_qy (qy_type,description,tablename)
         VALUES (qy_type,description,tablename)
    WHEN tablename = 'OTHER' THEN
    FROM myExternal

  • Jar file - trying to load audio from within it

    I am writing a Game using NetBeans. All works fine when run from within NetBeans, but problems occur when run from a JAR executable.
    The Audio files are not loading. I had a Similar problem with the Images, but resolved it with getResources() etc.
    Any help would be much appreciated, and will post my game when its finished, horray
         * Loads a sequence from the file system. Returns null if
         * an error occurs.
        public Sequence getSequence(String filename)
            try
                return getSequence( new FileInputStream(filename));
            catch (IOException ex)
                ex.printStackTrace();
                return null;
         * Loads a sequence from an input stream. Returns null if
         * an error occurs.
        public Sequence getSequence(InputStream is)
            try
                if (!is.markSupported())
                    is = new BufferedInputStream(is);
                Sequence s = MidiSystem.getSequence(is);
                is.close();
                return s;
            catch (InvalidMidiDataException ex)
                ex.printStackTrace();
                return null;
            catch (IOException ex)
                ex.printStackTrace();
                return null;
        }

    new FileInputStream(filename))That only works for files. Resources in JARs are not files. You should always (when possible) use getClass().getResourceAsStream() to open streams on resources, loading them from the classpath -- regardless of whether your app is a bunch of loose files or in a JAR.

  • Plz help....JAR file needed.......

    Hi Friends,
    I want to use the IUrlGeneratorService and IPortalUrlGenerator classes for a URL generation task. But I cannot find the JAR file having these classes. I tried finding com.sap.portal.appintegrator.sap.bwc_api.jar in my eclipse/plugins but could not find it.
    Where can I find this JAR, or any other JAR having the files I need?
    Plz help.

    Hi,
    You can find jar files from this link also
    <a href="http://www.alphaworks.ibm.com/aw.nsf/reqs/jarclassfinder">Jar Files</a>
    And check in your portalapps folder the name of the jar file for urlgenerator is bc.rf.global.service.urlgenerator_api.jar.
    Regards,
    Venkatesh.K.

  • Applet that archieve jar file fail to load picture

    hello...
    i already can display my applet , but the ploblem is the applet canot display the picture...
    the class that i include in the jar file is can run and will display the picture...
    wat is the ploblem?
    thanks...

    This is my full code
    package dir.yew;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import java.applet.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    public class DirTree
         extends JPanel {
         public static final String APP_NAME = "Directories Tree";
         public static final ImageIcon ICON_COMPUTER =
              new ImageIcon("computer.gif");
         public static final ImageIcon ICON_DISK =
              new ImageIcon("disk.gif");
         public static final ImageIcon ICON_FOLDER =
              new ImageIcon("folder.gif");
         public static final ImageIcon ICON_EXPANDEDFOLDER =
              new ImageIcon("expandedfolder.gif");
         protected JTree  m_tree;
         protected DefaultTreeModel m_model;
         protected JTextField m_display;
         public DirTree() {
              DefaultMutableTreeNode top = new DefaultMutableTreeNode(
                   new IconData(ICON_COMPUTER, null, "My Computer"));
              DefaultMutableTreeNode node;
              File[] roots = File.listRoots();
              for (int k=0; k<roots.length; k++) {
                   node = new DefaultMutableTreeNode(new IconData(ICON_DISK,
                        null, new FileNode(roots[k])));
                   top.add(node);
                node.add( new DefaultMutableTreeNode(new Boolean(true)));
              m_model = new DefaultTreeModel(top);
              m_tree = new JTree(m_model);
              m_tree.putClientProperty("JTree.lineStyle", "Angled");
              IconCellRenderer renderer = new
                   IconCellRenderer();
              m_tree.setCellRenderer(renderer);
              m_tree.addTreeExpansionListener(new
                   DirExpansionListener());
              m_tree.addTreeSelectionListener(new
                   DirSelectionListener());
              m_tree.getSelectionModel().setSelectionMode(
                   TreeSelectionModel.SINGLE_TREE_SELECTION);
              m_tree.setShowsRootHandles(true);
              m_tree.setEditable(false);
                   JScrollPane splitPane = new JScrollPane(
              new JScrollPane(m_tree)
              setLayout( new BorderLayout() );
              add( splitPane );
         DefaultMutableTreeNode getTreeNode(TreePath path) {
              return (DefaultMutableTreeNode)(path.getLastPathComponent());
         FileNode getFileNode(DefaultMutableTreeNode node) {
              if (node == null)
                   return null;
              Object obj = node.getUserObject();
              if (obj instanceof IconData)
                   obj = ((IconData)obj).getObject();
              if (obj instanceof FileNode)
                   return (FileNode)obj;
              else
                   return null;
           class DirExpansionListener implements TreeExpansionListener {
            public void treeExpanded(TreeExpansionEvent event) {
                final DefaultMutableTreeNode node = getTreeNode(
                    event.getPath());
                final FileNode fnode = getFileNode(node);
                Thread runner = new Thread() {
                        public void run() {
                             if (fnode != null && fnode.expand(node)) {
                                  Runnable runnable = new Runnable() {
                                       public void run() {
                                            m_model.reload(node);
                                  SwingUtilities.invokeLater(runnable);
                runner.start();
            public void treeCollapsed(TreeExpansionEvent event) {}
         class DirSelectionListener
              implements TreeSelectionListener {
              public void valueChanged(TreeSelectionEvent event) {
                   DefaultMutableTreeNode node = getTreeNode(
                        event.getPath());
                   FileNode fnode = getFileNode(node);
                   if (fnode != null)
                        m_display.setText(fnode.getFile().
                             getAbsolutePath());
                   else
                        m_display.setText("");
         public static void main(String argv[]) {
              JFrame frame= new JFrame( "FileSystem Viewer");
              DirTree dir = new DirTree();
              frame.getContentPane().add(dir);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.pack();
              frame.setVisible(true);
    class IconCellRenderer
         extends    DefaultTreeCellRenderer {
         public IconCellRenderer() {
              setLeafIcon(null);
              setOpenIcon(null);
         public Component getTreeCellRendererComponent(JTree tree,
              Object value, boolean sel, boolean expanded, boolean leaf,
              int row, boolean hasFocus) {
              // Invoke default implementation
              Component result = super.getTreeCellRendererComponent(tree,
                   value, sel, expanded, leaf, row, hasFocus);
              DefaultMutableTreeNode node =
                   (DefaultMutableTreeNode)value;
              Object obj = node.getUserObject();
              setText(obj.toString());
            if (obj instanceof Boolean)
                   setText("Retrieving data...");
              if (obj instanceof IconData) {
                   IconData idata = (IconData)obj;
                   if (expanded)
                        setIcon(idata.getExpandedIcon());
                   else
                        setIcon(idata.getIcon());
              else
                   setIcon(null);
              return result;
    class IconData {
         protected Icon   m_icon;
         protected Icon   m_expandedIcon;
         protected Object m_data;
         public IconData(Icon icon, Object data) {
              m_icon = icon;
              m_expandedIcon = null;
              m_data = data;
         public IconData(Icon icon, Icon expandedIcon, Object data) {
              m_icon = icon;
              m_expandedIcon = expandedIcon;
              m_data = data;
         public Icon getIcon() {
              return m_icon;
         public Icon getExpandedIcon() {
              return m_expandedIcon!=null ? m_expandedIcon : m_icon;
         public Object getObject() {
              return m_data;
         public String toString() {
              return m_data.toString();
    class FileNode {
         protected File m_file;
         public FileNode(File file) {
              m_file = file;
         public File getFile() {
              return m_file;
         public String toString() {
              return m_file.getName().length() > 0 ? m_file.getName() :
                   m_file.getPath();
         // Alternatively we copud sub-class TreeNode
         public boolean expand(DefaultMutableTreeNode parent) {
              DefaultMutableTreeNode flag =
                   (DefaultMutableTreeNode)parent.getFirstChild();
              if (flag==null)       // No flag
                   return false;
              Object obj = flag.getUserObject();
              if (!(obj instanceof Boolean))
                   return false;      // Already expanded
              parent.removeAllChildren();  // Remove Flag
              File[] files = listFiles();
              if (files == null)
                   return true;
              Vector v = new Vector();
              for (int k=0; k<files.length; k++) {
                   File f = files[k];
                   if (!(f.isDirectory()))
                        continue;
                   FileNode newNode = new FileNode(f);
                   boolean isAdded = false;
                   for (int i=0; i<v.size(); i++) {
                        FileNode nd = (FileNode)v.elementAt(i);
                        if (newNode.compareTo(nd) < 0) {
                             v.insertElementAt(newNode, i);
                             isAdded = true;
                             break;
                   if (!isAdded)
                        v.addElement(newNode);
              for (int i=0; i<v.size(); i++) {
                   FileNode nd = (FileNode)v.elementAt(i);
                   IconData idata = new IconData(DirTree.ICON_FOLDER,
                        DirTree.ICON_EXPANDEDFOLDER, nd);
                   DefaultMutableTreeNode node = new
                        DefaultMutableTreeNode(idata);
                   parent.add(node);
                   if (nd.hasSubDirs())
                        node.add(new DefaultMutableTreeNode(
                             new Boolean(true) ));
              return true;
         public boolean hasSubDirs() {
              File[] files = listFiles();
              if (files == null)
                   return false;
              for (int k=0; k<files.length; k++) {
                   if (files[k].isDirectory())
                        return true;
              return false;
         public int compareTo(FileNode toCompare) {
              return  m_file.getName().compareToIgnoreCase(
                   toCompare.m_file.getName() );
         protected File[] listFiles() {
              if (!m_file.isDirectory())
                   return null;
              try {
                   return m_file.listFiles();
              catch (Exception ex) {
                   JOptionPane.showMessageDialog(null,
                        "Error reading directory "+m_file.getAbsolutePath(),
                        DirTree.APP_NAME, JOptionPane.WARNING_MESSAGE);
                   return null;
    }

  • Gifs placed in a jar file. need help getting them.

    I have placed all the gif files in a jar file.
    added the gif.jar to the project in the required libraries of project properties.
    In the toolbar class I gave this.
    JButton btnNew = new JButton(new ImageIcon("new.gif"));
    and was expecting it to show the icon but I didn't get it?
    Can I place the gifs in a jar file.
    What else can I change/check to see the icons?
    Thanks.

    They are in the same path in the jar file that they were when they were on your disk in the file system. Lets say you have a dir structure
    C:\dir1\dir2\dir3\dir4\file.txt
    and you cd to dir2:
    cd \dir1\dir2
    then you jar dir3:
    jar cvf jar.jar dir3/*.*
    the path to file.txt would still be /dir3/dir4/file.txt inside the jar file.
    do a jar tvf jarfile.jar and take a look.

Maybe you are looking for

  • Cannot access my external hard drive!

    A few month ago when I was transferring my files from a PC via a Seagate external hard drive (originally formatted on that PC) to my then new Intel iMac OS X 10.5.6, I made a newbie mistake in not properly "dismounting" before I pulled the USB. Now I

  • Google fonts not displaying correctly since updating to Firefox 31.0

    Since updating to Firefox 31.0, the vast majority of Google / web fonts are not displaying correctly, including icons that are being replaced with random characters. When I view the Google web fonts page, only a few display correctly, the rest just d

  • Myterious character in text file! Please help!

    Hello all I am experiencing a problem identifying a certain character in a text file I have to import. In the .txt doc the char appears as a square, and when copying the text to MSWord, it seems like a paragraph sign. But when I'm searching for parag

  • Fix position of 3D graph in front panel

    Hi I haev used 3D graphs in my VI but whenever I open my vi I see that the position of 3D graph has changed in my Front Panel  and it takes a lot of time to rearange everything again. It also change the position of the other things like pics or  Tab

  • Setting a global workbook

    Hello ,   I have created one workbook template, and did the setting for global template so that it can be used for all the workbooks. But the problem is-- its opening in 2003 but giving problem with 2007. I am not able to open it in 2007.