masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then, seemingly, this org.jdesktop package is not repainting the textfield after the variables value changes.

Sounds like a question for where ever you got this this "org.jdesktop" package. You may be doing something wrong. In any case this "binding" is not a standard Java feature, but rather a specific "feature" of this third party library you're using, so, logically, you should be asking them.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There is no API, AFAIK, for that. That is not the sort of thing you want to be doing anyway. Runtime.exec and ProcessBuilder are, IMHO, tools of last resort and should not be the preferred execution path.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yeah, File. You read it and write it to copy, you listFiles to list them, and you use delete to delete them. Where's the problem?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google POI and/or Andy Khan's jxl.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

There are many Java Decompilers which can decomile .class file to .java file revealing the source.

Is there any way to prevent this reverse engineering ?

Of course. Provide a web service rather than a standalone application.

Like in .Net framework, once .dll or .exe is built, noone can reach to source code.

?:S

Wrong.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Does he ever get a Heap Space exception? Does he ever even fill at least have of the Heap Space? If not, it may just be that the JVM hasn't felt that a GC run has been necessary yet. Also, even if it has, Java only reserves from the system the min heap space, then, as that is surpassed will periodically reserve more until the Maximum Heap Space has been reached. But the JVM never releases that memory back to the System. So, even though the memory usage of the JVM seems to go up and up and up, from the System view, that doesn't mean there is any kind of memory problem. Find a profiler and monitor the actual Heap Space, not the system memory usage of the JVM.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

That's regex, but it shouldn't be that slow.

If you want to make it faster, search the Strings yourself, rather than using regex. That is, however, much more complicated.

Edit: And, even faster, would be to not bother creating the Strings at all, until you have found what you're looking for, and simply search the byte values as they are read (using a Stream, not a Reader).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What does Matcher's find() method return? Why are ignoring that return value?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I assume then that this "Connect : Direct (Network data mover)" is a specific product? If so, what is the link from which you got the info above?


I have the feeling though, that if this is a specific product, and google is not able to find a "free" Java API for it (Google "Java API NDM Network data mover" and/or "Java API Connect Direct") that there isn't any, and you will have to go to the company that produces this product and ask them if they have any (and then, probably, buy it).

Also, if it is a specific product, then I must assume you have some interaction with it already, and so already have the product, so you should be able to get any Java API they have at no additional cost.

If not, all you can do is sit down with a network sniffer and attempt to snoop out the protocol and implement it yourself.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The API documentation for the constructor your using says:

Creates a new PrintWriter, without automatic line flushing

The close() method should flush the stream before closing the file, but try calling flush before calling close.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

If you are producing an excel with the data, why cannot the user simply let excel generate the graph?

You are too tied up with Excel here.

In any case, try POI HSSF/XSSF or Andy Khan's jxl.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And, what, exactly, is "connect : direct (NDM)"? What do you mean by "I got reference of connect : direct (NDM)."?

If you don't know anything about what you're looking for, we can't help you much.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

As alludded to here, have you tried Google, yet? And if so, what did you try?

Also, do you mean "Network Data Model" (which is what most people understand behind the abbreviation NDM)? Try Googling that.

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

Just use split. See the API docs for String.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Why excel?

Google JFreeChart.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No difference. local variables get their stack addresses at the method level, so there is, truely no difference. Unless, of course, you wish to use that variable outside of the for loop.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

configure the servlet mapping in the web.xml properly.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

ok i'll c 4 mysql then.. i was tryin to solve it though java.. it seems little aukwrd no? thankx any way

The "solution" may be executing a specific SQL statement. In which case you can still use Java to execute it (even automatically within the life of an application), but Java cannot solve it.

Edit: Then again, the answer may be that you can't. That you would have to "recreate" the counter and repopulate the table with new values.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

But The problem may be, is that when you delete the records, the pointer for the next field to add is still at 16

Exactly.

and all you need to do, is insert in field 6 for example.

Yes, as already said, you can manually insert into (or update) this field, but that does not reset the counter.

probably you need to google that.
"how to manually insert in a field" or " how to override a field " that could give you an idea about the auto numbering in my opinion.

No, I'm sorry, but his best bet, as already said, is to read the manual (again if need be) first, then to ask (using a forum search there first) at the forums (and/or a mailing list) at www.mysql.org

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I'm sorry, but, this is a MySQL question, not a Java question. Go to www.mysql.org and find, and ask at, the forums there.

If you want to solve it with Java, the only thing you can do is to read all the keys, finding the missing numbers (i.e. 1 and 3 are used but 2 is not) and fill those values, as well as the continuing indexes (as that will not show what the last one used was) manually.

The MySQL documentation (of which there is a lot) may give some indication of how to reset the counter, though.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, I fixed the code. I have no problem with you trying to help, but I do have a problem with you providing seriously subpar "solutions" to something that has already been solved.

You would have been much better served to read the thread and try to understand what was being said rather than blindly plowing in with non-solutions that leave serious problems behind, when the real problems have already been solved.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Just simply don't include that field in the insert. i.e. you have table with field1 and field2 and field1 is auto_increment and field2 is varchar. So your query is insert into table (field2) values ('a')

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The same way you're using the other methods.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Instantiate your class in the main method and access those values through the reference

pulic class Bogus {
    public int x;
    public static void main (String[] args) {
        Bogus b = new Bogus();
        b.x = 5;
        System.out.println(b.x);
    }
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, what is wrong now? We can't read your mind, and I am not going to play both compiler and JVM and try to reconstruct it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What does the documentation say? But, no, probably not. There might be (in the Window -> preferences/options area) a way to designate "default" jars, but I doubt it.

Change the startup of NetBeans to include it on NetBeans' classpath and NetBeans will have access to it, which does not necessarily mean that the projects in NetBeans would have access to it. And, even if they did, it wouldn't help much in the end, as once you have built a deployment jar from the project it would no longer have that jar on it's calsspath and so wouldn't "work". Adding it to the project will cause NetBeans to include that jar in the projects "dist" directory and add it to the deployments jars classpath in its manifest.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The exception shown say it can't find main. The main method needs to have the following signature if you intend to use it to start your program

public static void main (String[] args) {

yours is

public void main (String[] args) {
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

Why?

How is

private boolean checkpword(){
    boolean b=true;
    pasWd = pword.getText() ;

    try {
        /*this works ok...>>>*/ResultSet pwrd = c.getData("Select Pword from users where userNm = '"+uname.getText()+"' ");
        while (pwrd.next()) {
            if (pasWd.equals(pwrd.getString("Pword"))) {
                b= true;
            } else {
                b= false;
            }
        }
    } catch(SQLException e) { }
    return b;// error wiil clear
}

better than

private boolean checkpword(){
    pasWd = pword.getText() ;

    try {
        /*this works ok...>>>*/ResultSet pwrd = c.getData("Select Pword from users where userNm = '"+uname.getText()+"' ");
        try {
            return ((pwrd.next()) && (pasWd.equals(pwrd.getString("Pword"))));
        } finally {
            try { pwrd.close(); } catch (Exception ex) {}
            // close the statement
        }
    } catch(SQLException e) {
        // log the exception, at least
        return false;
    }
}

Other than ignoring the exception (which is probably indicative of a larger problem), leaving db resources hanging which will eventually "kill" the app, and creating extra memory management that is completely unnecessary?

masijade 1,351 Industrious Poster Team Colleague Featured Poster
public class KeyGen {
  public static void main(String[] args) {
    System.out.println("key generator suggestion wcm");
  }
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, this is a Java forum. Was this meant to be a JavaScript question?

Java != JavaScript FYI BTW

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? And?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And, actually, I'm an idiot, as all you really need is

return ((pwrd.next()) && (pasWd.equals(pwrd.getString("Pword"))));

and a return false in the catch block, of course.

Edit: And add a finally block to close the resultset and the statement that created it, and probably the connection as well (if using a connection pool, otherwise I assume you are using the same connection throughout the app).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Personally, working with that framework, I would replace that while loop with

if ((pwrd.next()) && (pasWd.equals(pwrd.getString("Pword")))) {
    return true;
} else {
    return false;
}

Edit: And, of course, add some sort of log message, or something to that catch block. Also, you must also add a return false to that catch block, or throw an exception from the method, as, otherwise, in the case of an exception, there is still no return statement.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, you know what you intend, but the compiler does not. The compiler sees that you have declared the method boolean, but that if the while condition evaluates to false that there is no return value.

What, exactly, are you attempting to do with this method. I mean, I see what you are doing, but I don't know that it would actually do what you intended it to do.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What happens when pwrd.next() returns false? What is the return value then?

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

I don't believe you can. You would probably have to create your own Calendar implementation (in the way GregorianCalendar is an implementation of Calendar).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

For your java version simply type
java -version
for JCreator, I am sure it's documentation explains where and how to set the jdk and jre references.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Check the version JCreator is using in its preferences and then check which "java" is on your PATH. Seemingly the javac used by JCreator is newer than the java on your PATH. That is the only thing that causes this message, is when the compiler is newer than the jvm.

IOW, check again, as however you "checked" previously was not done right.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I would say to ask matlab support if they provide a Java API, as they are the ones who would provide it. The other option is to google for a thrid party API.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And your question/problem is?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, you should put something in there even if only a log statement. Another possibility is to make the method boolean as follows:

public boolean add(String crime) {
        try {
            CrimeType newCrime = CrimeType.valueOf(crime);
            crimes.add(newCrime);
        } catch(IllegalArgumentException e) {
            return false;
        }
        return true
    }

That way, you at least know something went wrong and can inform the user, and you never want to simply ignore Exceptions (well there are a few places where you can, although you should still, at least, log them).

Edit: Then change this

} else {
            System.out.println("\t\tThat is not a valid crime. The crimes are");
            crimes.list();
        }
        crimes.add(crimeName);

to this

}
        if (!crimes.add(crimeName)) {
            System.out.println("\t\tThat is not a valid crime. The crimes are");
            crimes.list();
        }
masijade 1,351 Industrious Poster Team Colleague Featured Poster

You entered "a" at the prompt, didn't you?

According to your enum class these

murder, arson, assault, fraud, theft, vandalism, drunk, littering, badHair

are the valid entries.

You might wish to wrap the line

CrimeType newCrime = CrimeType.valueOf(crime);

in a try catch block so that you can simply inform the user that (s)he entered an invalid value rather than having that crash your program.

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

As long as you installed Java correctly, then "double-clicking" (or however the target system handles launching programs from the "desktop") will work. Otherwise, it depends on the system. But, as long as you have a correctly configured manifest file in the jar, and you have installed java correctly, there is nothing more to do.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

clicking jar file says :
Could not find the main class (note : I created the manifest file)

Then you either did not configure the manifest file properly, or you did not include the main class in your jarfile.

clicking bat file says:
unsupportedClassVersionError: bad version number in .class file

:( Sory to bothr so much!!!

Then, as stated before, you are not using the correct version of java for either your compiling and/or executing.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

By making sure the right versions of java and javac are in your PATH (not CLASSPATH), or call the proper version explicitly.

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