masijade 1,351 Industrious Poster Team Colleague Featured Poster

I never said you see the source code (although with decompilation, you do, at least a "compatible" version of it). You see it's declared members and declared methods and declared constructors.

Edit: I.E. their "names", their types, their access level, and their parameters (with type).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Reflection, decompilation, javap, hell, on Unix, the strings command, not to mention that every IDE will show it to you (they can also show you the private and protected members). It is not a secret. The format of the byte code is publicly available, and so there are many ways to read it, and many ways to change it. Do not consider these access modifiers to be real world security measures.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There are no such thing as either golobal nor global vars. There are "constants" i.e. public static final variables, but they still need to be referenced through the class. That can be done in the imports however using a static import. I.E.

// class Test1
package test;

public class Test1 {
  public static final int cons = 1;
}

// Class Test2
package anotherPackage;

import static test.Test1.cons;

public class Test2 {
  public static void main (String[] args) {
    System.out.println(cons);
  }
}
javaAddict commented: Thanks for the new info +5
masijade 1,351 Industrious Poster Team Colleague Featured Poster

What about the following line (which is valid CSV) a,"b,c","d""e""f,g",h which should be

a
b,c
d"e"f,g
h

That's why you should look for a library, or you play around with indexOf and substring yourself (which I have been forced to do).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Bzzzzzzt! Gong!!!!! Wrong answer! We are not here to do your work for you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay, so what do you have so far. We are not here to do your work for you, but we are more than happy to help you correct yours.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Did you search for exactly "SQLite JDBC Driver". If so, the very first link works, but there are many others, and the third link (the one from sqlite.org) has a list of possible drivers. Take your choice.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then use .Net

Nick Evan commented: haha +11
masijade 1,351 Industrious Poster Team Colleague Featured Poster

after j.add add j.validate() and j.repaint(), and then try again.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because the only print statement you have there refers to one specific element (and actually it doesn't refere to any of them since index is undefined there).

You, of course, need to create another for loop in that case section just like under the case section 1.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
masijade 1,351 Industrious Poster Team Colleague Featured Poster

The first index of an array is 0, which means the last index of an array is one less than its length. So, knowing that, take a look at the condition in your for loop and see if can find and fix the problem.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Do you want to "set the element to 0" or do you want to remove it. The sample code will actually remove it. If all you want to do is set it to 0, then there is no reason to "record" the index when you find it, simply set it to zero then and there (or, more probably null, or setName to null or "", since the array contains objects, seemingly).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Implement Runnable unless you have some specific reason for extending Thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Manual. Gives full control with no "bolierplate", repetitive, rigid code.

But that's not what you're looking for is it? I dislike all "Gui builders", as they all produce rigid, reptitive code that is hard to modify correctly, and is not always that effecient when any action to be performed is more than popping up a dialog.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

How is javascript going to help with this when there is no server and no html, or anything else that has anything at all to do with JavaScript? Or is this really a download after all? Even though you said it wasn't? Is there a server now? Where did it come from if there wasn't one before? JavaScript would still have nothing to do with it though. Either parse the access log or only allow the "download" through a cgi/jsp/php/whatever rather than a direct link and have the page that delivers the file "increment the counter", as I already suggested in one of your other threads before you claimed that it wasn't a download at all.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, of course you're "not getting the exact reason for this" when you ignore all errors. Add a printStackTrace to each of those catch blocks.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It might help to know what these nebulous "errors" are. complete error message with stack traces (where applicable), please.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because what is automatically "converted" is the result of the operation, not the individual pieces of the operation. Therefore, the operation consists of two Integers 2/3, therefore Integer math is performed resulting in Integer 0. And the Integer 0, automatically converted to double is 0.0.

Edit: And what do you mean by

in java why we don't get zero in this situation

You do get zero in this situation, and for the reasons explained above.

Edit Again: Why do people simply refuse to believe either 1) there own eyes or 2) explanations from people who know, simply because their initial impression of their own code is "it should be right", even though it's not?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because 2 and 3 are Integers, so pure Integer math is performed.

Use a literal double (i.e. 2.0 instead of 2) or cast at least one of them to a double

double a = (double) 2 / 3;
// or
double b = 2 / (double) 3;
// or
double c = (double) 2 / (double) 3;
// or
double d = 2.0 / 3;
// or
double e = 2 / 3.0;
// or
double f = 2.0 / 3.0;
// or any combination of casting and literal doubles
kvprajapati commented: Helpful! +6
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Or Andy Khan's jxl (Don't believe this works as of Office 2007, however). As last resort you can use the JDBC-ODBC Bridge.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And your question is?

saadismail85 commented: just to know Is this acceptable ..? +1
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Good for you. A lot of people react negatively to that sort of advice, so, truthfully, way to go.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

it is a common problem when dealing with applet so you need to create an applet to view the output or if not an applet program look at the compillation options given to you after compilling

Huh? This is purely a compilation issue. What does applet, or not applet, have anything to do with it?

shashikant.v commented: thanks fo ur reply +1
masijade 1,351 Industrious Poster Team Colleague Featured Poster

$file_name, not file_name
ditto for the other variables
use "sed -e" not just "sed"
and change $file.new to ${file}.new just to be safe

Edit: So many problems, so little text. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

BufferedReader, readLine, a counter, and String's split.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because without the static, that Test t = new Test(); is an instance variable, that is instantiated with every call to new. So, you call new Test() in main, which triggers another new Test, which triggers another new Test, which triggers another new Test, which triggers another new Test, which trig.....

BestJewSinceJC commented: good advice :) +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Not a good beginning.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There is nothing wrong by putting the database connection in the JSP,

Yes there is. You have obviously never worked on anything that lasted more than a few days, or ever needed to be expanded or improved or fixed. Scriptlets are a maintenance nightmare. At the very least use a bean.

but you have to create a new database connection and query for every page you creates.

Hopefully you mean retreiving one from a Connection pool and not actually creating one with every query. That would be a performance nightmare.

This will reduse the performance and response on server. This is one of the problems.

(I guess you didnt mean using a pool.) Not with a Connection Pool, and every web container (which you must be using to use JSP) has a connection pool, so no problem.

Instead you could create a connection class and put it into application scope and the connection will be made when server is started. This is done only once. Then it is available for all objects that uses table info from the database.

Yet another bad suggestion. A static, single connection used by a dynamic (God I hate that word) threaded application? What happens when one thread calls rollback directly before another thread was about call commit? Or the other way around?


Connection Pools, Beans, and a properly implemented layered approach. Everything presented here is ....... well, I don't think I really need to say it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just use getDate.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By starting your own thread in the JavaScript forum, maybe?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Take a close look at my previous post.

The first code block is your code, the second code block is modifications to that code.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
BestJewSinceJC commented: Yeah, it's not your fault though. +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

You are calling the ethod without any arguments, but the method is designed to take an int and a double, so give it an int and a double.

pwk064 commented: Great help - Thanks! +0
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Write a method that reads the user input (I am assuming your getting input at various stages) and checks whether it is "quit" or not and otherwise returns the input as a String. Then, every place where you are currently reading input call this method instead.

tux4life commented: Good suggestion :) +6
javaAddict commented: Clever suggestion +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

That information seems to encapsulate a session, so Google around a bit and find out how to maintain a session using HttpURLConnection.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Change this

usbThread thread = new usbThread();

    public detectUSB() {
        initComponents();

        thread.start();
        

        final JLabel label = lbl_status;
        final String text = thread.getThreadStatus();

        SwingUtilities.invokeLater(
                new Runnable() {
                    public void run() {
                        label.setText(text);
                        label.validate();
                        label.repaint();
                    }
                }
            );
    }

to this

public detectUSB() {
        initComponents();
    }

and change this

public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new detectUSB().setVisible(true);
            }
        });
    }

to this

public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new detectUSB().setVisible(true);
            }
        });
        new usbThread(lbl_status).start();
    }

and change this

public class usbThread extends Thread{
    public String status=".....";
    usbThread()
    {
      
    }

    String getThreadStatus()
    { 
      return this.status;
    }

    @Override
    public void run() {
        ....
        this.status="FindDrive: waiting for devices...";
            ....
                this.status="Drive "+letters[i]+" has been plugged in";
            else
                this.status="Drive "+letters[i]+" has been unplugged";
                ....
            }
            try { Thread.sleep(100); }
            catch (InterruptedException e) { /* do nothing */ }
        }
    }

to this

public class usbThread extends Thread{
    private String status = ".....";
    private JLabel label;
    usbThread(JLabel label) {
        this.label = label;
    }

    private void postStatus() {
        SwingUtilities.invokeLater(
                new Runnable() {
                    public void run() {
                        label.setText(status);
                        label.validate();
                        label.repaint();
                    }
                }
            );
    }

    @Override
    public void run() {
        ....
        this.status="FindDrive: waiting for devices...";
        postStatus();
            ....
                this.status="Drive "+letters[i]+" has been plugged in";
            else
                this.status="Drive "+letters[i]+" has been unplugged";
                ....
            }
            postStatus();
            try { Thread.sleep(100); }
            catch (InterruptedException e) { /* do nothing */ }
        }
    }
majestic0110 commented: Patience of a Saint! +3
masijade 1,351 Industrious Poster Team Colleague Featured Poster

MS Access is file based (i.e. no remote connections, local file access needed) and Applets do not have access to the local file system. A complete redesign is in order.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Each package has it's own directory (in the normal state of affairs, there are other ways of doing it, but we won't get into those).

I.E. Hypothetical, your source code is under
/my/source
and your compiled code is under
/my/classes
then for the package
thisIs.myPackage
and the class
DontYouLikeIt
the java file should be located at
/my/source/thisIs/myPackage/DontYouLikeIt.java
and the class file should be located at
/my/classes/thisIs/myPackage/DontYouLikeIt.class

So, hopefully those "5 programs" all have the same package and not just "a pacakge".

Now, what exactly, is your problem?

masijade 1,351 Industrious Poster Team Colleague Featured Poster
cmd /c <command>

See http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

And read it completely and thoroughly, although I can't imagine why you would really want to do all this.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

PS: By the way, what is that counter for and how it is different from the reputation points?

On your profile page is a new "helpfulness percentage rating". These ups and down go toward that (the reputation still exists alongside this though, and these don't seem to affect that).

masijade 1,351 Industrious Poster Team Colleague Featured Poster
package thisIs.a.valid.packageAnd;
public interface MyInterface {
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Correct, and, as I said in your other thread, it is because the image file (as referenced there) doesn't exist. Read the API docs for the getResource method carefully and completely.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Start your own thread.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

JSplitPane?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That is what I said, that super() is added by the compiler, if you don't add a super call yourself. I simply illustrated what the code effectively was. In fact, if your classes looked like this

public class ClassA {
    public ClassA(String s) {
        System.out.println("Class A constructor " + s);
    }
}

public class ClassB extends ClassA {
    public ClassB() {
        System.out.println("Class B constructor");
    }

    public static void main(String[] args) {
        new ClassB(); // explicitly call ClassB constructor
    }
}

You will get the compiler message "Implicit super constructor ClassA() is undefined. Must implicitly invoke another constructor."

majestic0110 commented: Thanks for your input! +6
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because the first line of every constructor, is a call to a super constructor. If you do not add it yourself (i.e. call a specific super constructor) the compiler automatically adds a call to the default constructor of the super class. And, yes, obviously, this call will finish before the constructor in which it is to be found. To be complete your code is actually as follows:

public class ClassA {
    public ClassA() {
        super();  // the default constructor of Object
        System.out.println("Class A constructor");
    }
}

public class ClassB extends ClassA {
    public ClassB() {
        super();  // the default constructor of ClassA
        System.out.println("Class B constructor");
    }

    public static void main(String[] args) {
        new ClassB(); // explicitly call ClassB constructor
    }
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

project -> properties -> libraries -> add jar

mrnutty commented: Thanks man. +4
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google?

Ezzaral commented: Sounds about right to me. +25
masijade 1,351 Industrious Poster Team Colleague Featured Poster

java -jar <jarfile>

As stated in the tutorial that I linked to in one of your other threads.

majestic0110 commented: Good point! +5