Can compile, but cant execute

Hi, I can compile my program but I can't run it. Any help? This is the error:
Exception in thread "main" java.lang.NoClassDefFoundError: Spaceship
Caused by: java.lang.ClassNotFoundException: Spaceship
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:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Press any key to continue . . .
Here is my classpath value: C:\Program Files\Java\jdk1.6.0_07\lib;C:\apache-tomcat-5.5.26\common\lib\jsp-api.jar;C:\apache-tomcat-5.5.26\common\lib\servlet-api.jar;C:\Program Files\Java\jdk1.6.0_07\jre\bin;C:\Program Files\Java\jdk1.6.0_07\jre\lib;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Program Files\Java\jre1.6.0_07\bin;C:\Program Files\Java\jre1.6.0_07\lib
Here's my path: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Java\jdk1.6.0_01\bin;C:\apache-tomcat-5.5.26\common\lib;C:\Program Files\MySQL\MySQL Server 5.0\bin;C:\Program Files\Java\jdk1.6.0_07\bin
and my JAVA_HOME: C:\Program Files\Java\jdk1.6.0_07

[Javapedia: Classpath|http://wiki.java.net/bin/view/Javapedia/ClassPath]
[How Classes are Found|http://java.sun.com/j2se/1.5.0/docs/tooldocs/findingclasses.html]
[Setting the class path (Windows)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/classpath.html]
[Setting the class path (Solaris/Linux)|http://java.sun.com/j2se/1.5.0/docs/tooldocs/solaris/classpath.html]
[Understanding the Java ClassLoader|http://www-106.ibm.com/developerworks/edu/j-dw-javaclass-i.html]
java -cp .;<any other directories or jars> YourClassNameYou get a NoClassDefFoundError message because the JVM (Java Virtual Machine) can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.
javac -classpath .;<any additional jar files or directories> YourClassName.javaYou get a "cannot resolve symbol" message because the compiler can't find your class. The way to remedy this is to ensure that your class is included in the classpath. The example assumes that you are in the same directory as the class you're trying to run.

Similar Messages

  • .java file compiling but not executing in jdk6

    Using javac in jdk6 I can compile a .java file but cant executing the same using java command from my own directory. I can still compile and execute the same file from jdk\bin directory. I am using windows XP Home. While executing the .java file from my own directory, it fires a message: "The Java class could not be loaded. java.lang.UnsupportedClassVersionError: Myfilename (Unsupported major.minor Version 50.0)". i have set path in environment variable as "C:\sun\sdk\jdk\bin" where jdk placed in sun\sdk.
    Please help me to solve the problem

    This isn't information we can give you. You have to set it up based on your system.
    Do you understand how execution paths work? There's a list of filesystem paths, separated by a semicolon or a colon depending on the system, all concatenated into one big string. The entries earlier in the string are looked in first.
    So if your path has this:
    c:\Windows\java;c:\sun\sdk\jdk\bin
    Then if you type "java" from the command line, the Windows one would be executed, not the JDK 6 one.

  • Can compile but cannot run.

    Dear Java Guru,
    Wish to find out why I can compile but cannot run. I encounter the following error: 'Exception in thread "main" java.lang.NoClassDefFoundError: javax/media/jai/JAI
    at saveasone.<init>(saveasone.java:29)
    at saveasone.main(saveasone.java:21)'
    This does not happen on one PC but happened on another PC.
    The one can compile is XP, the other which cannot compile is Win2k Professional. Is there any other possible cause ?
    Please advise.

    The problem probably lies in the Classpath. I think you are using different environments for compiling and running. If you are using an IDE for developing your code, you might have set the classpath correctly there but not in the executing environment. As about the OS's you mentioned, I think the problem is still with your Environment Settings than OS settings.

  • My B+Tree can compile but have runtime error ... i can't tink why ...

    Sorry to bother anyone ... i have spent almost 3 weeks trying to debug the problem...
    My B+ Tree can compile but can't run as it throw invalid Null pointer Exception ..
    I suspected the error is in the split (int order ) method in the BTreeNode class but i can't remedy for it
    This my program code
    public class BTree {
    * The order of the B-Tree. All nodes of the B-Tree can store up to 2*order key values.
    private int order;
    * The number of key (with associated data values) stored in the B-Tree.
    private int count;
    * The root node of the B-Tree
    private BTreeNode root;
    * The first leaf node in the B-Tree. This field is used to give the starting point for sequential
    * access to the keys and data stored in the leaf nodes.
    private BTreeNode first;
    * The last leaf node in the B-Tree. This field is used to give the starting point for reverse
    * sequential access to the keys and data stored in the leaf nodes.
    private BTreeNode last;
    * A change count that can be used to invalidate iterators. This field is updated whenever a key plus data pair
    * is added to the B-Tree (or the data associated with a key is changed), or when a key plus data pair are
    * deleted from the B-Tree.
    private int changeCount = 0;
    // WHEN DOING ASSIGNMENT 5, DO NOT ADD ANY ADDITIONAL FIELDS TO THIS CLASS
    // You will loose marks if you add additional fields to this class. The fields above are all that
    // you need. If you need a variable in a method, use a local variable. I have seen too many
    // assignments where students add fields rather than create local variables. Hopefull the threat
    // of loosing (quite a few) marks will help reduce this habit.
    * A general exception class for errors when constructing or manipulating a B-Tree. Use the string
    * parameter to the constructor to say what the error really is.
    public class BTreeError extends RuntimeException {
    public BTreeError(String reason) {
    super(reason);
    * A constructor that creates an empty B-Tree of the given order.
    * <p/>This is the only constructor provided at the moment for this BTree class. Could consider
    * adding the equivalent of a 'copy constructor' that creates a new BTree object from an existing
    * BTree object.Constructor
    * creates the root of a btree
    * A constructor that creates an empty B-Tree of the given order.
    * <p/>This constructor need to copy the order parameter to the field of same name, and initialise the
    * root, cound, first and last fields of the BTree object.
    * @param order The order of the BTree.
    public BTree(int order) {
    count = 0;
    this.order = order;
    root = new BTreeNode(true, null, -1, null, null);
    first = root;
    last = root;
    * A method to return a SequentialIterator object that is positioned just before the first key
    * of the BTree object.
    * <p/>Do not modify this method.
    * @return A SequentialIterator object.
    public SequentialIterator iterator() {
    return new BTreeIterator();
    * A mehtod to return a SequentialIterator object that is positioned at a key found through a call
    * to the searchFor() method.
    * <p/>Do not modify this method.
    * @param position A SearchPosition() object that usually has been returne by a call to the searchFor() method.
    * @return A SequentialIterator object initialised to start at particular key in the BTree.
    public SequentialIterator iterator(SearchPosition position) {
    return new BTreeIterator(position);
    * A method to return a string representationo the BTree.
    * <p>The format of the string is:
    * <pre>BTree: Order=<digits>, size=<digits>, root=<BTreeNode string></pre>
    * <p/>Do not modify this method.
    * @return A string to represent the BTree
    public String toString() {
    StringBuffer s = new StringBuffer("BTree: Order=");
    s.append(order).append(", size=").append(size()).append(", root=").append(root.toString());
    return s.toString();
    * Method to determine the number of records stored in the B-Treee.
    * <p/>Do not modify this method
    * @return the number of records in the B-Tree.
    public int size() {
    return count;
    * method to return the order of the B-Tree.
    * <p/>
    * <p>This is the smallest number of key values for all nodes
    * except the root node. The maximum number of key values in a node is 2*order, and the maximum number
    * of child nodes for a node is 2*order+1.
    * <p/>Do not modify this method.
    * @return The order of the B-tree.
    public int order() {
    return order;
    * Insert a key plus data value into the BTree.
    * <p/>This method needs to locate the leaf node in which the key + data value should be
    * inserted, and then call the insertLeaf() method of BTreeNode to do the insertion.
    * <p/>This method will always result in a change to the BTree, so it should increment
    * the change count.
    * <p/>The method may result in only the data associated with an existing ke being changed,
    * so incrementing the count field should be done in the BTreeNode method (if needed).
    * <p/>This is one of the method you need to complete for assignment 5.
    * @param key The key associated with the data value to be added to the B-Tree
    * @param data The data value to be added (with it's associated key) to the B-Tree.
    public void add(Comparable key, Object data) {
    // you need to add the code for this method
    // i added
    BTreeNode btNode = root;
    while (!btNode.isLeaf) {
    int i=0;
    while(key.compareTo(btNode.keys) > 0) {
    i++;
    if (i == btNode.numberOfKeys) break;
    btNode = btNode.childNodes[i];
    btNode.insert(key,data);
    if (root.numberOfKeys == order*2-1) root.split(order);
    * insert a object with the given key into the tree
    //KeyNode keyNode = new KeyNode(key, data);
    // BTreeNode keyNode = new BTreeNode(key,data);
    BTreeNode btNode = root;
    while (!btNode.isLeaf) {
    int i=0;
    while(key.compareTo(btNode.key(i)) > 0) {
    i++;
    if (i == btNode.numberOfKeys())
    break;
    btNode = btNode.child(i); }
    System.out.println("hmm1");
    btNode.insert(key,data );
    System.out.println("hmm2");
    if (root.numberOfKeys == order*2-1)
    System.out.println("hmm3");
    root.split(order);
    System.out.println("hmm4");
    * This method searches the B-Tree for an occurence of the key in a leaf node and returns the result
    * of the search in a SearchPosition object.
    * <p/>Note that the key may occur in an interior node of the BTree without occuring in the leaf
    * nodes. This can be the result of a deletion operation. This method need to search down to the
    * leaf node that should contain the key if the key and associated data is in the B-Tree, and then
    * scan through the keys in the leaf node for the search key.
    * <p/>The result of the search is returned as a SearchPosition object, as this allow the return
    * of the success or failure of the search, as well as the data belonging to the key. It also
    * allows position information to be returned so that an interator can be initialised with the
    * key as the starting position for subsequent sequential access to adjacent keys.
    * <p/>This is one of the method you need to implement.
    * <p/>Implementation nodes:<br>
    * You need to find the leaf node that may contain the key (same code as for add()), then
    * scan the leaf BTreeNode for the search tree. You can do this within this method, as you
    * have total access to the fields and methods of BTreeNode (as BTreeNode is an inner class
    * of BTree). If you find the key, construct and return a SearchPosition object with the appropriate
    * details of the position, otherwise construct add return a SearchPosition object that indicates the
    * search failed.
    * @param key The key to search for in the BTree
    * @return A SearchPosition object returning the data and position information for the search
    public SearchPosition searchFor(Comparable key) {
    // You need to add the code for this method. The code below simply creates a
    // SearchPosition object which indicates an unsuccessful search.
    return new SearchPosition(false, null, -1);
    * A method to delete a node from the BTree.
    * <p/>The method should return the data object that was deleted when the key plus data object pair
    * are deleted from the B-tree.
    * <p/>The method should throw a BTreeError exception (with an appropriate reason string) if the
    * key is not found in the B-tree.
    * <p/>This is a method you can implement for bonus marks in Assignment 5.
    * <p/>Implementation notes:<br>
    * The easiest way to proceed is to use searchFor() to determine if they key is in the BTree, and
    * (if it is in the B-tree) to return position information about the key. Throw an exception if the
    * key is not in the B-tree, otherwise keep a copy of the data assocaited with the key (to return),
    * then for the leaf node containing the key (a BTreeNode object), call the deleteLeafNodeKey() method,
    * passing across the leaf key index of the key (so you don't have to find it again in the leaf node).
    * After this method deletes the key, return the data you saved as the method result.
    * @param key The key to delete (along with it's associated data) from the B-tree.
    * @return The data associated with the key that was deleted.
    public Object delete(Comparable key){
    // You need to add the code for this method.
    return null;
    * The inner class BTreeNode is used to represent the nodes in the B-Tree.
    * <p/>The nodes in the BTree are of two types:
    * <ol>
    * <li>Leaf nodes that contain the keys and associated data values, stored in ascending key order.<br>
    * These leaf nodes have next and previous pointers to adjacent leaf nodes to allow an easy
    * implementation of an iterator class to provide bi-directional sequential access to the keys stored
    * in the BTree nodes.
    * <li>Interior nodes that contain keys and links to child nodes (that are either all internal nodes
    * or all leaf nodes), organised as the node of a multi-way search tree. The interior nodes have
    * one more child node link than keys. The child node link at index k is to a node with keys that
    * are all less than the key at index k in this node. The link at index k+1 is to a child node
    * with keys that are all greater than or equal to the key at index k.
    * </ol>
    * The BTreeNode class allows you to create these two 'types' of nodes, depending on the parameters
    * passed to the constructor.
    * <p/>There are methods that should only be called for leaf nodes and methods that should only be
    * called for interior nodes. These methods should throw an exception if called by the wrong node
    * type. This class should really be designed using inheritance to mimic the pascal/C++ variant
    * record structure, but this design is relatively easy to understand and to implement.
    * <p/>Note that this class is an inner class of BTree, and so all objects will have an implict
    * reference to the BTree container object. This class has direct access to all the fields of the
    * BTree contaner object. In particular, the order of the BTree is available, hence this class
    * does not need to keep a copy of the order as a field.
    * <p/>Skeleton class provided for Objects and Algorithms Assignment 5
    * <p/>Only modify the methods where the JavaDoc indicates that you need to provide code.
    * @author a.sobey
    * @version 1.0
    * Date: 16/05/2005
    public class BTreeNode {
    * The actual number of key values stored in the BTreeNode. <br>Note that the BTree node has an implicit
    * reference to the containing BTree object, and the maximum number of nodes that can be stored in a
    * a BTreeNode (except temporarily during the split operation) is twice the <i>order</i> of the BTree.<br>
    * This field is valid for both internal and leaf nodes.
    private int numberOfKeys = 0;
    * The array of pointers to child nodes of this node. Only <i>(numberOfKeys+1)</i> are valid if <i>numberOfKeys</i>
    * is non-zero.<br>
    * This array is only valid and created for internal nodes - this array is not created for leaf nodes.<br>
    * There is space in the array created for one additional child node link - this makes the coding for
    * splitting of an internal node easier to implement.
    private BTreeNode[] childNodes;
    * A reference to the parent node of this node.<br>
    * This link is null if this node is the root node of the tree of BTreeNodes.<br>
    * This node is valid for both internal and leaf nodes.
    private BTreeNode parent;
    * The index in the parent node's array of links (the <i>childNodes</i> array) for the link to this node.<br>
    * This value should be set to -1 if this node is the root node (and so has no parent node).<br>
    * This field is valid for both internal and leaf nodes.
    private int parentIndex;
    * A link to the next leaf node in the B-tree, provided to allow easy sequential access of the keys
    * and values stored in the B-tree.<br>
    * This field is only valid if the node is a leaf node. For non-leaf nodes set the value to null.<br>
    * For leaf nodes, set the value to null if this node is the last leaf node in the B-tree.
    private BTreeNode next;
    * The link to the previous leaf node in the B-tree, provided ot allow easy reverse sequential access of the keys
    * and values stored in the B-Tree.<br>
    * This values should be set to null if this node is a leaf node but is the first leaf node in the B-Tree, or
    * if this node is not a leaf node.<br>
    * This field is only used in leaf nodes.
    private BTreeNode previous;
    * An array of comparable key objects that are stored in this node of the B-tree.<br>
    * Only the first <i>numberOfKey</i> values in the array are valid.<br>
    * The maximum number of keys in a node is 2*<i>order</i>, however there is space in this array
    * for one additional value to make the coding of the node splitting operation easier to implement.<br>
    * This field is valid for both internal and leaf nodes.
    private Comparable[] keys;
    * An array of data values associated with the keys stored in this leaf node of the B-tree.<br>
    * Only the first <i>numberOfKey</i> values are valid.<br>
    * The maximum number of data values in a node is 2*<i>order</i>, however there is space in this array
    * for one additional value to make the codingof the leaf node splitting operation easier to implement.<br>
    * This field is only valid for leaf nodes - for interior nodes this array is not created.
    private Object[] data;
    * A boolean value to indicate if the node is a leaf node or not. The structure of the remainder of the node
    * depends on this value (would be nice to have variant records in Java ...).<br>
    * This field is valid for both leaf and internal nodes.
    private boolean isLeaf;
    private int order;
    * The constructor for a BTreeNode.
    * <p/>The code for the constructor is provided - do not modify this constructor.
    * @param isLeaf True if this node is a leaf node.
    * @param parent A link to the parent node or null if this node is the root node of the B-Tree
    * @param parentIndex The index of the link in the array of child node linkes in the parent node that points to this node.
    * @param previous A link to the previous leaf node for sequentail access, or null if not a leaf node or no previous leaf nodes.
    * @param next A link to the next leaf node for sequential access, or null if not a leaf node or the last leaf node.
    public BTreeNode(boolean isLeaf, BTreeNode parent, int parentIndex, BTreeNode previous, BTreeNode next) {
    this.parent = parent;
    this.parentIndex = parentIndex;
    this.previous = previous;
    this.next = next;
    this.isLeaf = isLeaf;
    if (isLeaf)
    data = new Object[2 * order + 1];
    else
    childNodes = new BTreeNode[2 * order + 2];
    keys = new Comparable[2 * order + 1];
    public BTreeNode( int order, BTreeNode parent)
    this.order = order;
    this.parent=parent;
    this.keys = new Comparable[2*order-1];
    this.data = new Object[2*order-1];
    this.childNodes=new BTreeNode[2*order];
    this.isLeaf=true;
    * Returns the number of keys in this BTreeNode. Note that within the code in BTree you have access
    * to all the fields of BTreeNode, so this method is not strictly necessary.
    * @return The number of keys in this BTreeNode object.
    public int numberOfKeys() {
    return numberOfKeys;
    * Returns the container BTree object for this BTreeNode object. You may like to check that container objects
    * are the same when manipulating two BTreeNode objects.
    * @return the containing BTree object.
    public BTree container() {
    return BTree.this;
    * A private method to return a string representation of the array <i>keys</i>. This method is used in
    * the toString() method for this class.<br>
    * Do not modify the code provided for this method.
    * @return A string representation of this nodes array of keys.
    private String keyString() {
    StringBuffer s = new StringBuffer("{");
    for (int index = 0; index < numberOfKeys; index++)
    s.append(index > 0 ? "," + keys[index] : keys[index]);
    return s.append("}").toString();
    * A private method to return a string representation of the array of data values stored in a leaf node.<br>
    * This method is used in the toString() method of BTreeNode. The method does not check if this node is a
    * leaf node, as it is not intended to be called directly from outside of this class, and the toString()
    * method only calls this method if the node is a leaf node.<br>
    * Do not modify the provided code for this method.
    * @return a string representation of the data values array of a BTreeNode.
    private String dataString() {
    StringBuffer s = new StringBuffer("(");
    for (int index = 0; index < numberOfKeys; index++)
    s.append(index > 0 ? "," + data[index] : data[index]);
    return s.append(")").toString();
    * A private method to return a string prepresentation of the array of child node links in an interior node.<br>
    * This method is used in the toString() method. This method does not check if this node is an interior
    * node, so you must take care to only call this method for interior nodes.<br>
    * Do not modify the provided code for this method.
    * @return A string representation of the array of child nodes of this BTreeNode.
    private String childString() {
    StringBuffer s = new StringBuffer("<");
    for (int index = 0; index < numberOfKeys + 1; index++)
    s.append(childNodes[index] + (index == numberOfKeys ? "" : ","));
    return s.append(">").toString();
    * The toString method provides a string representation of a BTreeNode.<br> This particular method does not
    * include the details of all the fields of a BTreeNode. While debugging your code, you may like to include
    * more information (such as the parentIndex value), but in your final submission you must have the code
    * as provided in the skeleton BTreeNode class provided to you.
    * @return A string representation of a BTreeNode.
    public String toString() {
    if (isLeaf)
    return (new StringBuffer("[")).append(numberOfKeys)
    // .append(',').append(parentIndex) // uncomment this line if need to check parentIndex values
    .append(',').append(keyString()).append(',').append(dataString()).append(']').toString();
    else
    return (new StringBuffer("[")).append(numberOfKeys)
    //.append(',').append(parentIndex) // uncomment this line if need to check parentIndex values
    .append(',').append(keyString()).append(',').append(childString()).append(']').toString();
    * Returns the key with the given index in this node. Throws a BTreeError exception if the index is not valid.<br>
    * Do not modify this provided code.
    * @param index The index of the key.
    * @return The key value at the given index.
    public Comparable key(int index) {
    if (index < 0 || index >= numberOfKeys)
    throw new BTreeError("Key index out of range - value = " + index);
    return keys[index];
    * Returns the child node at the provided index into the childNodes array.<br>
    * A BTreeError exception is thrown if the node is not an internal
    * node or if the index is not valid.
    * <p/>Note that the child node returned will have keys that are all less than the key stored
    * in the <i>keys</i> array of this node at the given index value (except the last childNode
    * at index numberOfkeys, as this node has keys that are all greater than or equal to the last
    * key value stored in this node).<br>
    * Do not modify the provided code for this method.
    * @param index The index into the array of child nodes for this internal BTreeNode object.
    * @return The child node link.
    public BTreeNode child(int index) {
    if (isLeaf) throw new BTreeError("child() called for a leaf node");
    if (index < 0 || index > numberOfKeys)
    throw new BTreeError("Child node index out of range - value = " + index);
    return childNodes[index];
    * Returns the data value associated with the key at the given index. An BTreeError exception is thrown if the
    * node is not a leaf node or if the index is invalid.
    * <p/>Do not modify the provided code for this method.
    * @param index The index of the key assocaited with the data value.
    * @return The data value associated with the key with given index.
    public Object data(int index) {
    if (!isLeaf) throw new BTreeError("data() called for an internal node");
    if (index < 0 || index >= numberOfKeys)
    throw new BTreeError("Data index out of range - value = " + index);
    return data[index];
    * This method is used to determine if this node is a leaf node.
    * @return True if this node is a leaf node.
    public boolean isLeaf() {
    return isLeaf;
    * Inserts the (key, data) pair into this BTreeNode object.
    * <p/>You must supply the code for this method.
    * <p/>Implementation notes:<br>
    * <ol>
    * <li>Throw an exception if this node is not a leaf node.
    * <li>Scan the keys array for index of the key greater than or equal to the insertion key.
    * <li>If the key at the index is equal to the insertion key, update the data field and return - you are done.
    * <li>Otherwise shuffle the keys values from the insertion index along to make a hole for the insertion key,
    * and insert the insertion key into the keys array. Do the same for the data array values to insert the
    * new data value into the data array at the insertion index.
    * <li>increment the number of keys, and increment the container BTree object's count field.
    * <li>If the number of keys in the node is now no more than 2*order, you are done, so simply return.
    * <li>Otherwise the node has (2*order+1) key values, and need to split. The split operation leaves the first
    * <i>order</i> keys and data values in this node (and so the node's numberOfKeys value will become
    * <i>order</i>, and moves the remaining (order + 1) keys and data values to a new BTreeNode leaf node
    * that you need to create.<br>
    * You need to fix up the previous and next fields of this leaf node and the new leaf node you have created.<br>
    * Two sub-cases:
    * <ol>
    * <li>If this node is the root node (i.e., it does not have a parent node), the split of this node will create
    * a new root node, with a single key (the key at index (order+1)) and this node and the new BTreeNode as
    * the child nodes. In my solution I used a call to the method newRootNode to do this. The newRootNode()
    * method will also be used when a split of an interior node creates a new root node. See the JavaDoc for
    * details of what the newRootNode() method should do. Once the new root node has been created, and all
    * the fields updated due to the split, you are done.
    * <li>Otherwise we need to insert in this node's parent node the middle key (at index (order+1) and the
    * new node that we created. This is done by the method insertInterior(). The method is passed the
    * key to insert (at location this.parentIndex in the keys array of the parent node), the index to
    * to insert the key (this.parentIndex), and the new leaf node (that will be inserted at index
    * (this.parentIndex+1) in the parent node's child links array).
    * </ol>
    * </ol>
    * @param key The key to insert into the leaf node.
    * @param data The key's corresponding data value.
    public void insertLeaf(Comparable key, Object data) {
    // You need to provide the code for this method.
    // BTreeNode temp = new
    int size = this.data.length;
    int counter = 0;
    this.keys[size] = key;
    this.data[size] = data;
    sort(size);
    public int compareTo(Comparable o2) {
    // Integer o1 = (Integer) o2;
    return (((Integer)o2).compareTo(this));
    *split()
    *Splits a node into to nodes. This can only be done, if the node is full
    *The midlest key go up into the parent, the left ones of them rest in
    *this node, and the right ones go into a new node.
    private BTreeNode split(int order) {
    if (numberOfKeys == order*2-1) {
    BTreeNode right = null;
    if (parent == null) { // algo for the root-node
    BTreeNode left = new BTreeNode(order, this);
    right = new BTreeNode(order, this);
    for (int i=0; i<order-1; i++) {
    left.keys[i] = keys[i];
    left.data[i] = data[i];
    right.keys[i] = keys[order+i];
    right.data[i] = data[order+i];
    if (!isLeaf()) {
    for (int i=0; i<order; i++) {
    left.childNodes[i] = childNodes[i];
    left.childNodes[i].parent = left;
    right.childNodes[i] = childNodes[order+i];
    right.childNodes[i].parent = right;
    left.isLeaf = false;
    right.isLeaf = false;
    } else isLeaf = false;
    keys[0] = keys[order-1];
    numberOfKeys = 1;
    left.numberOfKeys = order-1;
    right.numberOfKeys = order-1;
    for (int i=1; i<order*2-1; i++) {
    keys[i] = null;
    data[i] = null;
    childNodes[i+1] = null;
    childNodes[0] = left;
    childNodes[1] = right;

    * Don't post that much code. There should never be a reason to. You should be able to break your code down into small enough pieces that you can post a small example that demonstrates your problem.
    * When you do post code, use [code] and [/code] tags to make it readable. You can use the code button on the message entry page.
    * The stack trace will tell you which line the NPE occurred on, where it was called from, where that was called from, etc. You can use that to help you find your error. Look at the line it's complaining about. What references are on that line followed by a dot, and what arrays do you try to access the elements of. One of those must be null.
    * Now that you know what[b] is null, put in a bunch of print statements to track [b]how it got to be null.

  • Can receive, but cant send mail

    Any ideas? I can receive but cant send mail. It says..
    The SMTP server “mailhost.zen.co.uk” rejected the password for user
    Have mail version 4.4
    Many thanks

    Hi,
    I would double check your settings and port numbers.
    Incoming Mail (pop3) server mailhost.zen.co.uk and port for Incoming mail (POP3) is 995
    Outgoing Mail (smtp) server mailhost.zen.co.uk and port for Outgoing mail (SMTP) is 587

    Also make sure under SMTP that the outgoing server requires as secure connection (SSL) box is checked as well as the incoming POP3 (SSL) box.
    Can you say if this is a recent issue or one that has been there since setup?

  • I can compile but not run ...

    Exception in thread "main" java.lang.NoClassDefFoundError: VierOpEenRij
    I can Compile my file VierOpEenRij.java , then it creates his .class but when I try to open it ( java VierOpEenRij ) then it says this error.
    anyone has an Idea how come , cause I really need it for school !!
    Thx

    No it still doesn't work ..
    If using -cp . does not work (don't forget the spaces), then either VierOpEenRij.class file does not exist in the current directory or the class inside the VierOpEenRij.class file is not named VierOpEenRij
    I don't know how , It used to work but now it just
    fails :(
    is it possible that i Intalled something that
    interrupte the proces ?Anything is possible.

  • Can compile but can't run....

    Last year I compiled and ran programs and applets with the Java SDK Version 1.4.0 on Windows XP. This year I am basically going thru the same motions, but now I can compile programs but not run them. The error that I get using the DOS prompt command is
    C:\VMBwork>java HelloWorld
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
    I moved to a new Computer Lab over the summer, so the technicians loaded j2sdk1.4.2_04 with NetBeans IDE. I have set the path in XP to c:\j2sdk1.4.2_04\bin and the classpath to c:\Program Files\Java\j2re1.4.2_04\lib\ext. This appears to be the same set up as last year...but no java programs run.
    I even tried loading j2sdk1.4.2_05 new on my computer without Netbeans with the same path changes, but to no avail. Any suggestions? The students are really anxious to get into programming.

    C:\VMBwork>java HelloWorld
    Exception in thread "main"
    java.lang.NoClassDefFoundError: HelloWorldIs HelloWorld.class in C:\VMBwork?
    Is HelloWorld.java defined in a package?
    If answers are yes and no (respectively), you should be able to run using
    java -cp . HelloWorld>
    I moved to a new Computer Lab over the summer, so the
    technicians loaded j2sdk1.4.2_04 with NetBeans IDE. I
    have set the path in XP to c:\j2sdk1.4.2_04\bin and
    the classpath to c:\Program
    Files\Java\j2re1.4.2_04\lib\ext. ^^^^^^^^^^^^ doesn't help for classpath (it's already set this way and you can't change that).
    -Alexis
    This appears to be
    the same set up as last year...but no java programs
    run.
    I even tried loading j2sdk1.4.2_05 new on my computer
    without Netbeans with the same path changes, but to no
    avail. Any suggestions? The students are really
    anxious to get into programming.

  • .java files compile but cannot execute

    Hello,-
    I have a small problem in that the compiler can find the .java file (javac javaFile.java), however the execute command (java javaFile) does not work (Exception in thread "main" java.lang.NoClassDefFoundError: javaFile). I'm using Windows Vista and JDK 1.6.0_02. Which one of the environment variables is responsible for file execution?
    Thanks beforehand, Vahagn

    @ smithberry: Now it executes! Thanks for pointing that out and apologies for not seeing the space before the filename. But how come this is at all necessary? Do I have to run all my java programs with this command from now on, including the JUnit TestCase extensions?

  • CAN COMPILE BUT CANNOT RUN PROGRAM

    I am finally able to compile my program, I have the extensions .class, when I try to run the program I get an error message "main"java.lang.noclassdef
    after message appears after I type java Saluton or whatever program I am trying to run.
    Any suggestions, someone justed I use textpad, but I don't think this has anything to do with not being able to run programs, I am using windows 98 second edition.

    This is a CLASSPATH problem.
    For example, if your .class file is in the directory C:\javaclasses then you would set the CLASSPATH environment variable to that using:
    set CLASSPATH=C:\javaclasses
    Add this to your autoexec.bat and reboot so you don't have to type this every time you open a DOS prompt.
    You may want to add the current directory, ., to the list of directories (use ; to separate directories).
    set CLASSPATH=.;C:\javaclasses
    If your class is part of a package, you have to use the directory that is the parent of the packages' directories.

  • Can receive but cant send MMS

    I  recently changed from a Tmobile to a EE sim keeping the same number but now I cant send MMS.  My phone device is a Cubot P9 Anriod 4.2.2. I have tried the sim in a old phone and still the same problem.

    Hi ,
    Thanks for joining the Community.
    Have you tried using our online photo message setup tool?
    Click here to go straight to it.
    Thanks
    James

  • Can receive but cant send 8520

    Please Help Can't send emails but can receive I've tried service books I get the save to draft when I want to send :-(

    On your BlackBerry device, go to:
    1. Options > Advanced > Host Routing Table > Menu > Register.
    2. Resend your service books from your carrier BIS site:
    From your handheld device:   http://www.blackberry.com/btsc/KB15402
    Go to the Personal Email Set Up icon and log in. Then under Help!, select Service Books, then select Send service Books.
    From your desktop PC:  http://www.blackberry.com/btsc/KB02830
    North American Carriers - scroll down to select your carrier
    WorldWide Carriers - Find your carrier on the list
    3. With the BlackBerry device powered ON, remove the battery a few seconds and then reinsert the battery to reboot. This reboot, even if you have already done this, is often needed to install the service books.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • CAN RECEIVE BUT CANT SEND EMAILS

    My email service was working just fine till recently! I can receive emails but can't send any cause the "SEND" option is not there anymore can someone help out

    Cheesyflyestgee wrote:
    Used browser and created email,checked default service,got on host routing table clicked register,sent service books and restart phone with power on[pulled battery out for 60sec] but still no luck
    Did you RECEIVE any registration message your BlackBerry?
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Compiling but not executing

    import java.util.Random;
    * A guessing game of high/low
    class HighLow {
       * a randomly generated number to be guessed
      private int number;
       * indicates if number has been guessed or not
      private boolean guessed;
       * Initializes the game, setting number to be something
       * between 0 and upperBound
       * @param upperBound the maximum that the number can be
      public HighLow( int upperBound ) {
        if( upperBound < 0 ) {
          upperBound *= -1;
        // a random number generator
        Random r = new Random();
        // set the number to a random number
        // between 0 and upperBound
        number = r.nextInt( upperBound );
        guessed = false;
       * Initializes the game, setting number to be something
       * between lowerBound and upperBound
       * @param upperBound the maximum that the number can be
       * @param lowerBound the minimum that the number can be
      public HighLow( int lowerBound, int upperBound ) {
        // a random number generator
        Random r = new Random();
        // set the number to a random number
        // between 0 and upperBound
        number = r.nextInt( upperBound - lowerBound );
        number = number + lowerBound;
        guessed = false;
      // accepts an integer. prints out if that
      // argument is higher than, lower than, or
      // equal to number
      public void check( int guess ) {
        if( !guessed ) {
          if( guess > number ) {
            System.out.println( "Too high" );
          } else if( guess < number ) {
            System.out.println( "Too low" );
          } else {
            System.out.println( "Good job!" );
            guessed = true;
        } else {
          System.out.println( "You already guessed it! It's " + number );
    }error: Exeption in thread "main" Java.lang.nosuchMethodError : main

    1) You do not have to make a new message for each error, it still applies on the same thread.
    2) where is your main part of the application ? Are you trying to run an applet ?

  • Can preview, but cant download

    I was using the Nokia Ovi player to download music, thanks to the 12 month unlimited subscription I got with my music phone.
    Then in September Nokia updated the software and I have not been able to download any music since. The file download fails, the only thing that did work was the 30second preview.
    I have been emailing back and forth to Nokia support who are convinced the problem is firewall and anti virus based. Eventually I got nowhere and bought a brand new PC, so with a fresh install no AV or Firewall I downloaded the Nokia Music player, and same thing!!!
    I then went and bought a Wireless MiFi and amazingly on the same computer, and music files started to download no problem!! Clearly it was a connectivity issue.Unfortunately due to the crazy cost of cellular data I cannot afford this route, so need to get it working on my adsl line.
    I suspected a port problem so checked my router was unblocked (to the best of my knowledge) and then called the ISP who ported into my router and confirm all unlocked and that they provide me a totally unshapped, unlocked connection.
    So I am well and truly stuck, can anyone help?
    THANKS!

    Had same problem with my PC, have contacted nokia Ovi by both email and Phone and got the same reply, then at end of phone call was told try again 24 to 48 hours later as it looks to be an ovi software problem.
    48 hours later and completed up date of ovi music player and still not down loading.
    3 albums now paid for and unable to download, only get download failed on every try.
    Any one out there got any Ideas.

  • TS1382 My ipod classic shows a x and wont start, can reboot but cant do anything elts

    hit the Menu and middle butten and reset it, but nothing else works.
    tried to hit play/pause and middle after apple logo, but that didnt work

    this happend to me with my old ipod
    just let it sit near a window where or anywhere the sun will heat it so the water evaporates then try it
    if not just take it to apple

Maybe you are looking for