How to use Vector or other ArrayList etc to store my JTree??

How to use Vector or other ArrayList etc to store my JTree??
Dear friends,
I have following I posted before, but not get satisfactory answer, so I modify and repost again here.
I have following code can add classes and students in the JTree,
in class Computer Science, it has student Bill Brien,
in Math, no,
Then I I add Student Nancy, Laura, Peter into Computer Science Class,
add AAAA, BBB, CCC into Math class,
I create a new class called Chemistry, then I add DDD int Chemistry;
so this JTree is dynamically changed,
[1]. How can I dynamically save my current JTree with all above tree structure and its nodes in a Vector or ArrayList(not sure which one is best)??
see code below:
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
public class ModelJTreeTest extends JFrame {
  private JTree tree;
  private DefaultTreeModel model;
  private DefaultMutableTreeNode rootNode;
  public ModelJTreeTest() {
    DefaultMutableTreeNode philosophersNode = getPhilosopherTree();
    model = new DefaultTreeModel(philosophersNode);
    tree = new JTree(model);
    JButton addButton = new JButton("Add Class/Students");
    addButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent event) {
        addPhilosopher();
    JButton removeButton = new JButton("Remove Selected Class/Students");
    removeButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent event) {
        removeSelectedPhilosopher();
    JPanel inputPanel = new JPanel();
    inputPanel.add(addButton);
    inputPanel.add(removeButton);
    Container container = getContentPane();
    container.add(new JScrollPane(tree), BorderLayout.CENTER);
    container.add(inputPanel, BorderLayout.NORTH);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(400, 300);
    setVisible(true);
  private void addPhilosopher() {
    DefaultMutableTreeNode parent = getSelectedNode();
    if (parent == null) {
      JOptionPane.showMessageDialog(ModelJTreeTest.this, "Select Class", "Error",
          JOptionPane.ERROR_MESSAGE);
      return;
    String name = JOptionPane.showInputDialog(ModelJTreeTest.this, "Add Class/Students:");
    model.insertNodeInto(new DefaultMutableTreeNode(name), parent, parent.getChildCount());
  private void removeSelectedPhilosopher() {
    DefaultMutableTreeNode selectedNode = getSelectedNode();
    if (selectedNode != null)
      model.removeNodeFromParent(selectedNode);
  private DefaultMutableTreeNode getSelectedNode() {
    return (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
  private DefaultMutableTreeNode getPhilosopherTree() {
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Students");
    DefaultMutableTreeNode ancient = new DefaultMutableTreeNode("Computer Science");
    rootNode.add(ancient);
    ancient.add(new DefaultMutableTreeNode("Bill Brian"));
    DefaultMutableTreeNode math = new DefaultMutableTreeNode("Maths");
    rootNode.add(math);  
    DefaultMutableTreeNode physics = new DefaultMutableTreeNode("Physics");
    rootNode.add(physics);
    return rootNode;
  public static void main(String args[]) {
    new ModelJTreeTest();
}the actual Tree dynamically created somehow looks like following:
                         |            1.Peter
                         |---CS---    2. Nancy
                         |            3. Laura
                         |            4.Brian
                         |
Root(University): -------|---Math- 1.AAA
                         |            2.BBB
                         |            3.CCC
                         |
                         |
                         |---Chemistry- 1. DDDThanks a lot
Good weekends

you can't directly store a tree in a list.Ummm... Just to be contrary... Yes you CAN store a tree in a table.... In fact that's how the windows file system works.
Having said that... you would be well advised to investigate tree data-structures before resorting to flattening a tree into a list.
So... Do you have a specific requirement to produce a List? Your umming-and-erring about Vector vs ArrayList makes it sound like you're still at the stage of choosing a datastructure.
Cheers. Keith.

Similar Messages

  • HT4463 I got I tune gift cards...I'd like to use them purchasing other items at apple store...BUT they appear geared only to purchase tunes...it keeps referring me to billing information even though I have money in credit

    I got I tune gift cards...I'd like to use them purchasing other items at apple store...BUT they appear geared only to purchase tunes...it keeps referring me to billing information even though I have money in credit

    Credit balances do not expire. First, make sure you're logged into the iTunes Store using the account ID and password you set up, or used, when you redeemed your cards.  If you are, try signing out of the account and back in.
    If you're sure you are using the correct account and that you're signing in to the iTunes Store, and signing out and back in doesn't help, go to the Purchase History and review your purchases to make sure that you should indeed have a balance left. iTunes doesn't always refresh the balance it shows, so it's possible you spent the money and it just wasn't being reflected in the display, thought it would be unlikely that you spent the entire balance unless you have a credit card on file as well.
    If you confirm that you should have balance left but the iTunes Store isn't showing it correctly, go here:
    iTunes Support
    and follow the instructions to report the issue to the iTunes Store.
    Regards.

  • How to use vector in JTable? Please help......

    Hi there
    I can use JTable using object array to manupulate data but it has a limitation of defining number of rows of the array. Alternatively i want to use vector. Anyone help me how to convert to using vector.
    Regards.
    mortoza, Dhaka

    hi,
    you could either use javax.swing.table.DefaultTableModel because this class uses a java.util.Vector for data storage or you could implements your own TableModel by extending javax.swing.table.AbstractTableModel.
    best regards, Michael

  • How to use Vectors ?????????

    Hi guys, i am a newbie in java and about to die due to some stressful assignments. I am not asking u to help in assignment. Just please share some knowledges about vector. How to use it? so that i can use it in my assignment. Thank u .
    AND IN THIS CODE BELOW: WHY DO WE HAVE TO IMPORT MARK;
    THERE IS ANOTHER CLASS CALLED MARK DEFINED ELSEWHERE.
    import java.util.Vector;
    import Mark;
    public class Student {
    private String name;
    private Vector subjectResults; // the implementation of the relationship from Student - Mark
    public Student (String name) {
    this.name = name;
    subjectResults = new Vector ();
    public void insertMark (int value) {
    this.subjectResults.addElement (new Mark (value)); // WHAT DOES THIS LINE MEAN ?
    public int findHighestMark () {
    int size = subjectResults.size (); //cache the result
    int highestMark = 0;
    for (int i = 0; i < size; i++) {
    Mark result = (Mark) subjectResults.get (i); //WHY DO WE HAVE TO PUT "(MARK)" ?
    if (result.get () > highestMark) {
    highestMark = result.get ();
    return highestMark;

    I'm going to guess that Mark is a class provided to you. Do you have the Mark.java file? Or only Mark.class? If you have Mark.java, see if the first line is package Mark;
    It shouldn't be.
    You shouldn't need to import Mark.
    A vector is a like a dynamic array (not really, but in simple terms it is), you can keep adding things to it. You can insert stuff in the middle, you can extract stuff from the middle (doesn't leave a gap).
    You use it with:
    public void addElement(Object toAdd)
    public Object elementAt(int index)
    These are the two most important methods of Vector.
    Note that it returns an Object. You won't be able to do anything useful with an Object (except for toString()), so you'll need to cast it to whatever you're expecting (Student or Mark or something).
    That's the basics of Vectors, hope this helps,
    Radish21

  • How to use File Splitter ($1.99) from App. store --By Tong Zhou

    I purchased File splitter from app. store ($1.99) by Tong Zhou.  I  cannot find instructions in English on how to use it!  I also tried to contact Tong by e-mail, but e-mail address didn't work etc.  His support page is in Chinese language  I haven't removed it from my Mac yet and hope to use it sometime.  ---have tried different drag and drop tactics, but no luck.  The lady at the app. store offered me a refund, but still hoping for instructions. 
    Thank you for any input!

    Hi,
    Have you triedthe standard oracle replace function?  replace(v('APP_USER'),'_','.')
    Otherwise it might be useful to add emailadress as column to your users table, just in case your business decides to change email adress format to [email protected]
    Regards,
    Vincent
    http://vincentdeelen.blogspot.com

  • How to use a visa gift card in itunes store

    Can you use a visa gift card in the itunes store and if so how do you set it up?

    You cannot.
    Gift cards are country specific.
    You cannot use the U.S itunes store from the U.K.
    Send the card back to someone in the U.S who can use it.

  • HT1918 how to use debit card for purchase in itunes store?

    i want to use debit card to purchase in itunes store and App store. How to change my account information using debit card?

    Debit cards are no longer accepted in the iTunes Store, it seems. The current valid payment methods are listed here:
    http://support.apple.com/kb/HT5552
    Using a debit card in any online service where it stores your card is a bad idea in any case since if someone gains access to your account in the service, they can quickly drain your bank account. Credit cards limit your liability, as do prepaid iTunes cards.
    Regards.

  • How to use own or other creditcard in Family Share?

    Hello together,
    i'm using the Family Sharing functionality(for example my dad set up the Family Share), great ideal. But now i want to buy an App on my own and do not want to use the Family-Creditcard but my own creditcard (sometimes i want to pay on my own).
    Each time i buy an App in the AppStore the Money is taken from the creditcard which is registered for Family Sharing.
    is there a way to decide which creditcard Shall be used for buying an App?
    if yes, were i have to change which creditcard shall be used?
    Or is there no function to decide and only the "Family" creditcard of my father  is used?
    please help,
    thankx

    you can't directly store a tree in a list.Ummm... Just to be contrary... Yes you CAN store a tree in a table.... In fact that's how the windows file system works.
    Having said that... you would be well advised to investigate tree data-structures before resorting to flattening a tree into a list.
    So... Do you have a specific requirement to produce a List? Your umming-and-erring about Vector vs ArrayList makes it sound like you're still at the stage of choosing a datastructure.
    Cheers. Keith.

  • [SOLVED] How to use timidity++ and other programs at the same time?

    I have installed timidity following arch wiki instructions - I have soundfont, and I start it in /etc/rc.conf
    It works properly with tuxguitar (and tuxguitar-alsa) or kmid, but I cannot play MIDI and - for example - oggs in amarok at the same time.
    I suspect that the problem is that timidity doesn't use dmix alsa plugin I have made in my ~/.asoundrc.
    The question is: how to tell timidity to use my dmix plugin?
    Last edited by senjin (2007-11-19 19:53:50)

    but they don't define "default" there, but "!default"...
    anyway, I have already both "default" and "!default" defined exactly the same way:
    pcm.!default
    type plug
    slave.pcm "dmixer"
    pcm.default
    type plug
    slave.pcm "dmixer"
    pcm.dmixer
    type dmix
    ipc_key 1024
    slave
    pcm "hw:0,0"
    format "S32_LE"
    channels 2
    period_time 0
    period_size 1024
    buffer_size 4096
    rate 44100
    bindings
    0 0
    1 1
    ctl.dmixer
    type hw
    card 0
    pcm.w_y_h
    type hw
    card 0
    device 0
    pcm.what_you_hear
    type plug
    ttable.0.10 1 # digital mix left
    ttable.1.11 1 # digital mix right
    slave.pcm w_y_h
    pcm.skype
    type asym
    playback.pcm "dmixer"
    capture.pcm "skype_input"
    pcm.skype_input
    type dsnoop
    ipc_key 2048
    slave
    pcm "hw:0,0"
    period_time 0
    buffer_time 0
    period_size 1024
    buffer_size 8192
    rate 44100
    and it doesn't work!
    Last edited by senjin (2007-11-18 17:49:21)

  • How to use vector file without adobe illustrator?? please help

    I am using the free trial period of adobe illustrator to creat a logo.  I don't want to buy illustrator b/c I don't plan on using the program for anything else,  I would like to save my logo in some kind of vector format so I can use it for lots of different printing options.  But I can't figure out how to do this b.c my computer won't open the file without illustrator.  Is there anyway to creat a usable print friendly logo without buying illustrator? Thanks for any help!

    I believe if you export it to wmf or emf you will have a Vector file that can be used in word or powerpoint and can be placed in other programs as can ai files which can be placed in word or powerpoint documents as vector files.
    Flash (swf) is another way of saving it and it is also vector.
    However even though you say you will never have use for Illustrator which is what I thought in 1995 when I use it to create a logo, I soon found more use for it and every year since have found a project that has rewarded me many times the cost of the application once I had purchased it. Most of which I never thought I had the need for and probably would not have even made the attempt to make the effort and the profit if I did not own the license.
    And every time I say to myself what do i have this application for the opportunities arises yet again.
    I thought I would share my experience with you.

  • How to use Multimaps (Map String, ArrayList String )

    I was using an array to store player names, userIDs, uniqueIDs, and frag counts, but after reading about multimaps in the tutorials, it seems that would be much more efficient. However, I guess I don't quite understand it. Here's how I wanted things stored in my string array:
    String[] connectedUsers = {"user1_name", "user1_userid", "user1_uniqueid", "user1_frags"
                                            "user2_name"...}and here is how I'm attempting to setup and use the 'multimap':
    public class Main {
        static Map<String, ArrayList<String>> connectedUsers;
        public void updatePlayers(String name, String status) {
            String[] statusSplit = status.split(" ");
            if (connectedUsers.containsKey(name)) {
                connectedUsers.put(name, statusSplit[0]);
            else {
                connectedUsers.put(name, statusSplit[0]);
        }It's quite obvious I don't understand how this works, but should I even set this multimap up this way? Perhaps I should use a regular map with a string array for the values?

    You're cool MrOldie. Its just that alarm bells start ringing in my head when people come on and post as much as you do.
    * Created on Jul 28, 2005 by @author Tom Jacobs
    package tjacobs;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.Map;
    import java.util.Set;
    import java.util.TreeSet;
    * ManyMap is a map that allows more than one value to be stored with any key
    * <p>
    * There are a number of methods in the class that have been deprecated because
    * the original functionality of Map has been violated to accomodate the concept
    * of the ManyMap
    public class ManyMap<T, T2> implements Map<T, T2> {
         private HashMap<T, ArrayList<T2>> mInnerMap;
         public ManyMap() {
              mInnerMap = new HashMap<T, ArrayList<T2>>();
          * @deprecated
         public T2 get(Object obj) {
              ArrayList<T2> ar = _get(obj);
              if (ar == null || ar.size() == 0) {
                   return null;
              return ar.get(0);
         public Iterator<T2> getAll(Object obj) {
              ArrayList<T2> ar = _get(obj);
              if (ar == null || ar.size() == 0) {
                   return null;
              return ar.iterator();          
         public T2 put(T obj1, T2 obj2) {
              ArrayList<T2> ar = _getNotNull(obj1);
              ar.add(obj2);
              return obj2;
         public Set<Map.Entry<T, T2>> entrySet() {
              TreeSet<Map.Entry<T, T2>> entries = new TreeSet<Map.Entry<T, T2>>();
              Iterator<T> _i = mInnerMap.keySet().iterator();
              while (_i.hasNext()) {
                   T key = _i.next();
                   Iterator<T2> vals = mInnerMap.get(key).iterator();
                   while (vals.hasNext()) {
                        Entry<T, T2> entry = new Entry<T, T2>(key, vals.next());
                        entries.add(entry);
              return entries;
         public int size() {
              return mInnerMap.size();
         public int valuesSize() {
              int vals = 0;
              Iterator<T> _i = mInnerMap.keySet().iterator();
              while (_i.hasNext()) {
                   T key = _i.next();
                   ArrayList<T2> ar = mInnerMap.get(key);
                   vals += ar.size();
              return vals;
         public void clear() {
              mInnerMap.clear();
         public void putAll(Map<? extends T, ? extends T2> map) {
              Iterator _i = map.entrySet().iterator();
              while(_i.hasNext()) {
                   Map.Entry<? extends T, ? extends T2> entry = (Map.Entry<? extends T, ? extends T2>) _i.next();
                   put(entry.getKey(), entry.getValue());
         public Collection <T2> values() {
              LinkedList ll = new LinkedList();
              Iterator<ArrayList<T2>> _i = mInnerMap.values().iterator();
              while (_i.hasNext()) {
                   ll.addAll(_i.next());
              return ll;
         public boolean containsValue(Object val) {
              Iterator<ArrayList<T2>> values = mInnerMap.values().iterator();
              while (values.hasNext()) {
                   if (values.next().contains(val)) return true;
              return false;
         public boolean containsKey(Object key) {
              return mInnerMap.containsKey(key);
         public T2 remove(Object obj) {
              Iterator<ArrayList<T2>> values = mInnerMap.values().iterator();
              boolean found = false;
              while (values.hasNext()) {
                   if (values.next().remove(obj)) {
                        found = true;
              return found ? (T2)obj : null;
         public boolean isEmpty() {
              return valuesSize() == 0;
         @SuppressWarnings("hiding")
         private class Entry<T, T2> implements Map.Entry<T, T2> {
              T key;
              T2 val;
              public Entry (T obj1, T2 obj2) {
                   key = obj1;
                   val = obj2;
              public T2 getValue() {
                   return val;
              public T getKey() {
                   return key;
              public T2 setValue(T2 obj) {
                   return val = obj;
         public Set<T> keySet() {
              return mInnerMap.keySet();
         public ArrayList<T2> _get (Object obj) {
              return mInnerMap.get(obj);
         public ArrayList<T2> _getNotNull (T obj) {
              ArrayList<T2> list = _get(obj);
              if (list == null) {
                   list = new ArrayList<T2>(1);
                   mInnerMap.put(obj, list);
              return list;
    }Edited by: tjacobs01 on Aug 19, 2008 12:28 PM

  • Sample code is required on how to use TableUI element in ArrayList

    Hi all
    Can any body send the sample code on how to store Table UI element in Arraylist.
    Regards
    Suresh babu

    Hi I am providing two methods of it. Just go through and try. This will defenately solve your problem
    I. METHOD
    Try This
      //@@begin others
    //this is the array used in the program
      String emp[][]=
           {"nikhil","tapkir","pune"},     
          { "juhi","bhatnagar","delhi"},
      //@@end
    i have to insert the above information in a table wid columns firstname lastname and city .
    u need to use the for loop to insert the data in the table for more than 1 record
    code the following thing in wd init
    here fname lname and city are my value attributes mapped to my table columns.
    for (int i=0;i<emp.length;i++)
           IPrivateTabappView.ITablenodeElement tnode=wdContext.createTablenodeElement();
           tnode.setFname(this.emp<i>[0]);
           tnode.setLname(this.emp<i>[1]);
           tnode.setCity(this.emp<i>[2]);
          wdContext.nodeTablenode().addElement(tnode);
    i hope this is what ur doubt was if not pls clarify.
    hope this helps u.
    II METHOD
    For example: Consider that the value node DataNode having two attributes A and B is bound to the DataSource property of your Table UI Element.
    IDataNodeElement objDataNode = null;
    ArrayList arlDataNode = null;
    int size = 0;
    size = <No. of rows that you want in the table>;
    arlDataNode = new ArrayList();
    for(int i=0;i<size;i++)
    objDataNode = wdContext.createDataNodeElement();
    objDataNode.setA(<Set some values>);
    objDataNode.setB(<Set some values>);
    arlDataNode.add(objDataNode);
    wdContext.nodeDataNode.bind(arlDataNode);
    Hope, You can resolve your problem. Revert me if you have any doubts.
    Regards
    Raghu

  • How can use ' Vector ' in JSP

    I use rs.getString(1); can get three strings like "12:00-13:00", "01:00-02:00", "02:00-03:00" from sql 2000. I would like these time one by one, if it equals user select. System will show the message...then I use following code...but doesn't work because jsp said Vector not a type.(cannot resolve).... I would like to know any other methods can do the same things. hope sb help... thank you
    Vector stringVector = new Vector();
    while(rs.next()){
    stringVector.addElement(rs.getString(1));
    Iterator sv = stringVector.iterator();
    while (sv.hasNext()){
    if(time.equals((String)sv.next())
    out.println("wrong");
    else{
    ......

    I personally would use an ArrayList. From what I hear, it's better than a vector. You want to make sure that you include the line at the top
    <%@ page import = "java.util.ArrayList" %>
    ArrayList stringVector = new ArrayList ();
    while(rs.next()){
    stringVector.add(rs.getString(1));
    for (int i =0; i < stringVector.size(); i++){
       if(time.equals((String)stringVector.get(i))
       out.println("wrong");
    else{No need to bother with any of that iterator stuff. My guess is that you're not including the Vector below, or a required jar file is missing (but Vector is part of the core java package, so the file can't be missing)

  • Time machine questions... how to use with an external drive etc.

    Hi,
    I am about to start using Time Machine. I have a few questions:
    1. Can Time machine be used to restore data and applications / application settings?
    2. I have a CalDigit VR eSATA drive which is 1TB RAID 1 which I was going to use as the Time Machine target drive.
    Does Time machine store all of its data files in one main folder with many sub folders?
    If my TM backup data takes up 600GB on the drive can I safely store other data on the 400GB or is it best to partition the drive HFS+ Journaled 600/400 and leave TM to its own dedicated partition?
    3. Does TM keep adding data until it runs out of disk space and only then delete older BUs?
    4. Is TM a good backup software for total recovery or is something like SuperDuper better? I would almost never use TM to recover a file that was deleted... but I am looking for a way to protect against data lost in the case of HD failure.

    If you haven't found this yet, take a look here: http://www.apple.com/findouthow/mac/#tutorial=leopardtimemachine
    That should give you a rough idea of the "look and feel."
    1. Can Time machine be used to restore data and applications / application settings?
    Yes, unless you tell it not to, it saves everything (except some system caches, temp files, etc.). If your HD fails, you can recover your entire system to a new/repaired HD via your Leopard install disc (it has the restore utility) and your TM backups. OS, apps (Apple and 3rd-party), preferences, settings, data, the whole system.
    Does Time machine store all of its data files in one main folder with many sub folders?
    As you may be able to see in the video, the small Finder window is very much like the main one; you can see your data in the same way. TM presents a "picture" that appears to be a full, separate backup of the way your Mac looked at any time. Of course, that's an illusion. It only actually copies files/folders that have been added or changed since the last backup.
    You can't tell which items are "real" and which are the "multi-links" representing a file that didn't change on that particular backup.
    For more info on the internals: http://www.appleinsider.com/articles/07/10/12/roadto_mac_os_x_leopard_timemachine.html
    3. Does TM keep adding data until it runs out of disk space and only then delete older BUs?
    Sort of. After an initial Full backup, it does incrementals (hourly, if you let it). Then it converts the first of the day to a daily backup, which it keeps for a month, and deletes the other hourlies after they're 24 hours old.
    After a month, it converts one per week into a weekly backup and deletes the dailies.
    It keeps the weeklies until it runs out of room, then begins deleting the oldest. But because of the "multi-links," it doesn't delete it's copy of anything that's still on your internal HD. So it manages it's space and deletions automatically and intelligently.
    4. Is TM a good backup software for total recovery or is something like SuperDuper better?
    They both have their advantages and disadvantages. Many of us use a clone plus TM. The clone advantage is, of course, being bootable. TM isn't. TM's advantages are the very fast incremental backups (it doesn't have to examine every file and folder to see what's changed): the ability to restore old items; and the ability to restore your entire system to a previous state, even if that's a prior version of Leopard!

  • JGSL : about java scientific library, how to use it any tutorial or etc

    Hay,
    I have a question regarding JGSL: java scientific library.
    I just download the jgsl.0.1.1 lib for my project
    It contains a bunch of file, including the lib files
    I set the lib folder path in the LD_LIBRARY_PATH and when i tried to run the testfile.class
    that comes with this library, i got an error
    main class defination not found.
    Have any one used the lib if yes can send me the working example.
    or at least tell me how to set these things, there is no documentation available with this.
    thanks

    Why don't u use a class loader. Try this code
    // loader class
    public class Loader  extends ClassLoader {
        String path;
        public Loader(String path) {
              this.path = path;
        public Class findClass(String name) {
            byte[] b = loadClassData(path+name+".class");
            return defineClass(name, b, 0, b.length);
        private byte[] loadClassData(String name) {
            File file = new File(name);
            byte[] data = null;
            try {
                InputStream in = new FileInputStream(file);
                data = new byte[ (int) file.length()];
                for (int i = 0; i < data.length; i++) {
                    data[i] = (byte) in.read();
            catch (IOException ex) {
            file = null;
            return data;
    // in your caller class use
       Loader loader = new Loader(libPath); // lib path may be taken from a command line arg
       Object main = loader.loadClass("ClassLib", true).newInstance();I think this is what u r looking for
    Uditha Nagahawatta

Maybe you are looking for