javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try this:
changeValue('<%=i%>')

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What are perfect numbers?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Actually if you use the getDate(), it will return a java.sql.Date, which doesn't hold the milliseconds.
When I want to get date from database I usually do this at the query:

TO_CHAR('format', date_column);

And then use the ResultSet.getString() method

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I know the methods, but when i use them they throws java.lang.NullPointerException

You get that exception because you haven't initialized the objects. You have create something with "new" in order to use it.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When you reply to the thread there is this symbol: #
above the area where you write.
Push it and put your code inside it. Use different code tags for each of your classes

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use code tags

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I tried to compile it in linux but it didn't work.

If it didn't work, why didn't you post the errors you were getting in first place?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi everybody,
I have found these books

Learning OpenCV: Computer Vision with the OpenCV Library from AMAZON

and this:
Learning OpenCV from my LOCAL store

Which one do you suggest to buy?
Should I wait and order the first one?
OR
is the second at my local store as good as the first

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public void split() {
      String s3 = "what ever the text you wish to have with new lines";
      String [] temp_store= null; // array to store the separated string
      temp_store = s3.split("/n"); // /n is the new line and it will get divide from there and get saved in the array
      
    // have a FOR or a WHILE loop and print it
  }

It will not work because the 's3' variable doesn't have the the '\n' character.
And it depends on the way you read the file. The most common way is to read it line by line so you will never have the '\n' in the String read. With every loop you will have the next. What is required (if i understood correctly) is to find a way to separate the paragraphs.
So like I said whenever you read an empty line you have a new paragraph. It depends on how you want to save the lines read

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There are many examples on how to read files in this forum. After you read each line, check if it has value an empty String:

if (line.trim().equals("")) {
 // this is an empty line
 // the new line would be the start of a new paragraph
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you corrected the other methods as well?

-----------------------------------------------------------
Also:
Just to make something clear to the other readers of this thread.

I didn't look at the code you sent me via PM. I found the error at the part of the code you posted just before you edited it and removed it.

This has nothing to do with you Frostra. You have written your code, had a question and asked it with respect to the forum rules.

I just don't want the other new guys thinking that they can send me their questions via PM and I will send them the answers. I only pay attention to what is posted

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also I haven't looked the rest of the code but this seems to be ok:

return a.add(b.mul(x)).add((c.add(d)).mul(x.power(6)));
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You didn't have to PM me the code. I was in the middle of writing this and the error is very obvious and very common.
Let's take these lines:

result.setRe(Math.pow(result.modulus(),n)*Math.cos(n*result.arg()));
result.setIm(Math.pow(result.modulus(),n)*Math.sin(n*result.arg()));

Firstly this: result.setRe(Math.pow(result.modulus(),n)*Math.cos(n*result.arg())); You correctly take the power of modulus, multiply it with the cos of the angle and you get the real part. BUT then you set it to the "result" complex number (WRONG). Therefor you change the real part of the original number (result). So when you try to calculate at the second line the "im" part and you call:
Math.pow(result.modulus(),n)
the result.modulus will not return the value that the previous line returned. Since you changed the real part of the result, you will return a modulus that has the new real part and the old im part at the second line.
So try this:

double a = Math.pow(modulus(),n) * Math.cos(n*arg());
double b = Math.pow(modulus(),n) * Math.sin(n*arg());

return new ComplexNumber(a,b);

Do not modify and use to your calculations the same object. Modify the new Complex object, but use the values of the existing number to set the results.

Also at the toString method maybe you need this:

String im_sign=(im < 0)?"-" : "+";

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Try to debug and see the values of the variables.
Or add "System.out.println" at several places in your code.

If you have a big piece of code then explain which part doesn't work and how you have coded that part. Maybe I will understand from your explanation what is the problem.

Try to split the code into small pieces, put them into methods and test them separately.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The point is that you don't do something through java if it can done through sql which is faster. So try to provide a better explanation about what you are trying to do.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You don't specify what is your problem.
And if this doesn't work:

return ((a.add(b.mul(x))).add((c.add(d))).mul(x.power(6)));

there is no way to understand what is wrong.
Better try splitting them and printing the result separately to see where the error is

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

ya sure
its in my office desktop.
i will bring n post here on monday.
thanks.

Till Monday then

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Don't forget to close the ResultSet, the Statement, and the Connection.
Also instead of while you could use an 'if'.
If more than one row is expected, use 'while', but like this:

returnInfo = "";
while (rec.next()) {
				returnInfo += "DVD : " + rec.getString("Title") + "\t"
						+ rec.getString("Genre") + "\t"
						+ rec.getString("Category") + "\t"
						+ rec.getString("Cost") + "\n";
			}
if(returnInfo.equals("")){
	returnInfo="No Results Found";
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well you have seen what append does and what setText does. If I remember correctly the setText simply sets the entire text of the Area with the input argument.
So it's up to you how to proceed.

If you want to get the entire String text from the Area, you might want to use the split method of the String class in order to separate the lines:

String [] arrayLines = area.getText().split("\n");

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You have already mentioned the append method. But I mentioned the setText method. Maybe you should give it a try.
Try getting the text, modify it and then use the setText

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
Ezzaral commented: Good suggestion +21
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Which method are you using?
There is the JTextArea.append and the JTextArea.setText.
I believe you understand what they do.
It is always best to check the API when you don't know why something doesn't work

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi, I am trying to use this method:
cvCheckArr

As a parameter I pass an IplImage and it compiles, but when I tried to run got this error:

"Unsupported format in function: cvCheckArr .cxmathfuncs.cpp "

I checked the above file and found from the code that it tries to convert the argument const CvArr* arr into a CvMat. The problem is that I pass an IplImage.

What I am trying to accomplish is to take the difference of 2 images and see if pixels of the result are lower than a certain threshold:

cvSub( frame, oldFrame, dst, NULL );
		
int diff = cvCheckArr(dst, /*flags*/ 0,/*min*/ 0,/*max*/ 120);

Don't mind the other values (0,0,120), the problem is that it doesn't run.
Do you know any other way to accomplish what I am trying to do?

Thanks.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Loop through the list like an array. Only this time use the size() as upper limit. Use the get(int i) method to get the element of the list.

Have you looked at the API for the List? If you are having problems with a class, always look the API:

http://java.sun.com/j2se/1.5.0/docs/api/java/util/List.html
http://java.sun.com/j2se/1.5.0/docs/api/java/util/ArrayList.html


And about masijade's code. You were supposed to fill the little dots with your code. The code that puts elements in the list

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well, it's not about what he wrote. It's about his approach to problems and the expectation of spoon feeding which, by all means, should be discouraged. At least this is what I think.

Of course that kind of behavior should be discouraged. I just thought that this:

I hope you don't post again; not such a post, at least.

was somehow . . . too direct.

Anyway, by the looks of it, it doesn't seem that the OP will return with some code of his own

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you want to call a method like that : Customer2.setName it should be static.

In your case it is correct to have them NON-static; but you create a
"Customer" objetct: Customer customer = new Customer(); and them call the "Customer2" ??
What are you trying to do??

Shouldn't you be doing this:

List<Customer2> list = new ArrayList<Customer2>();


Customer2 customer = new Customer2();
customer.setName(record[0]);

Notice I use the "customer" instance in order to call the non-static method.


If you already have a "Customer" class with the right attributes (name, address, ...) then use that class and do not declare them again at Customer2

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I hope you don't post again; not such a post, at least.

Even though you are right, that was rather rude. You could have suggested for mmmusa to post what he has done so far if he/she want some real help, instead of discourage him like that

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In java, you don't need to add this character at the end of an array: '\0'

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

the array 'f' is null. You need to instantiate it with new and set its size

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do it yourself!!

That was very rude.
You judge others when yourself have created 2 identical threads with the same question.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I did tried both and found relevant sites like the one provided. The problem was that I didn't know how to add the openCV library to my projects. The VS version I was using didn't have the options described at the link. I tried to download the latest VS Express edition but it was not installing.

Luckily I tried it at my work's laptop which didn't have an VS versions installed and it worked.

I will try to uninstall the VS I have installed in my old laptop and try again with the new Express edition.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi all, I am having problem with openCV:
I am using Microsoft Studio 2008
From this lnk: http://sourceforge.net/projects/opencvlibrary/ I downloaded the OpenCV_1.1pre1a.exe for windows and installed it.

I have been searching ways to include the libraries installed but the instructions don't seem to match my VS version?

So after creating a new project I went to the folder where the .cpp and .h files were and started adding the .h files that were installed.
(cv.h ,cxcore.v and so on)

The code was compiling but when I added the highgui.h I got this error:

Error 1 error LNK2019: unresolved external symbol _cvReleaseImage referenced in function _main HelloWorld.obj MyOpenCV
Error 2 error LNK2019: unresolved external symbol _cvWaitKey referenced in function _main HelloWorld.obj MyOpenCV
Error 3 error LNK2019: unresolved external symbol _cvShowImage referenced in function _main HelloWorld.obj MyOpenCV
Error 4 error LNK2019: unresolved external symbol _cvMoveWindow referenced in function _main HelloWorld.obj MyOpenCV
Error 5 error LNK2019: unresolved external symbol _cvNamedWindow referenced in function _main HelloWorld.obj MyOpenCV
Error 6 error LNK2019: unresolved external symbol _cvLoadImage referenced in function _main HelloWorld.obj MyOpenCV
Error 7 fatal error LNK1120: 6 unresolved externals C:\Users\USER\Documents\Visual Studio 2008\Projects\MyOpenCV\Debug\MyOpenCV.exe MyOpenCV

The code was taken from an example on the internet:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "cv.h"
#include "highgui.h"


int main(int argc, char *argv[])
{
  IplImage* img = 0; 
  int height,width,step,channels;
  uchar *data;
  int i,j,k;

  if(argc<2){
    printf("Usage: main <image-file-name>\n\7");
    exit(0);
  }

  // load an …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Sorry for the double posting
Again internet connection problems. Clicked the submit button, page did not redirect after several minutes and I pressed the button again

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You mean that you don't know what this for-loop does?

for (int i_14_ = 0; i_14_ < i_12_; i_14_++) {

or this:

if (class100s[i_14_ + i] == null)
		class100s[i_14_ + i] = Class68_Sub8.aRSString_2871;

Or are you saying that we should say what the Class68_Sub8's attribute (aRSString_2871) has as value?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You mean that you don't know what this for-loop does?

for (int i_14_ = 0; i_14_ < i_12_; i_14_++) {

or this:

if (class100s[i_14_ + i] == null)
		class100s[i_14_ + i] = Class68_Sub8.aRSString_2871;

Or are you saying that we should say what the Class68_Sub8's attribute (aRSString_2871) has as value?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

2nd thing keep in mind that while converting a String to Date - take care of format according to your database. Some may take as mm/dd/yyyy or dd/mm/yyyy. So, accordingly pass the parameter to SimpleDateFormat constructor.

Hope it solves your problem. And do let me know.

If the column in the DB is declared to be type Date, the format is irrelevant. Because the column will contain Date not a Varchar. The data int the column doesn't have a format nor it needs one because it is type data. You can put data inside it in any way you want as long it is type Date.

Check for these sql functions:
to_date(), to_char()

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

depending on the value of i_0_ it calls certain methods with some parameters and returns them

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You need to print the elements of the array.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

one other problem, how do i make so that no numbers repeat?

Already been answered:

Whenever you generate a new random number before you put it at the array check if the array already has it. If it does calculate it again, else put it and generate the next number.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can at least use this:

<input type="password" name="pass" id="pass" />

When the user clicks the button use javascript to get the value of the field and do whatever you want.
But you shouldn't use javascript for password authentication

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can search this forum for examples on how to use the BufferedWriter class:

BufferedWriter writer = null;
		try {
			writer = new BufferedWriter(new FileWriter(new File(fileName)));
				writer.write("Write this to file");
				writer.newLine();
		} catch(Exception e) {
			System.out.println(e.getMessage);
		} finally {
try { if (writer!=null) writer.close(); } catch (Exception ex) {}
		}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

what are you trying to accomplish?
Beacause when a main calls a main method, the second main will again call the main method, which will again call the main method, which will again call the main method, which will again call the main method,
OH NO, the stack is full, you have too many mains running; I can't take it anymore.
So naturally you get an error.
I haven't read the code, better explain it first. Maybe there is another way to do it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

//amount of accounts : 320
Account #/PIN/amount/type
30 39743 57.35 b
44 61405 68.96 l
9935 25686 2.67 l
9941 77300 9.8 b

Posting hundrends of lines will help us understand but if you just posted a few line like I did wouldn't ?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I believe you can use the name attribute as well. Also I think that you are closing the for loop at the wrong place. With your way it should have been after the <tr>

for(int i=0;i<f.length && f[i]!=null ;i+=3){%>
      <tr>
         <td> 
	<form action="cart.jsp" method="get">
	     <%out.println(f[i+1]); %><br>  
	     <%out.println(f[i+2]); %> $ <br>
	     <input type=submit value="delete" name="submit_<%= i%>">
          </form>		
         </td>
      </tr>
<%} %>

And in a servlet you can take all the parameters from the request and check whose name starts with "submit_":

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html#getParameterNames()

Enumeration en = request.getParameterNames();

The String after the "_" will be something to help distinguish which element you want to delete

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Whenever you generate a new random number before you put it at the array check if the array already has it. If it does calculate it again, else put it and generate the next number.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Read carefully my latest post

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Create a seperate Project with some classes and then you can import these classes like you import any other class:

import java.util.*

The only difference is that you will be importing your classes with their packages.
You can take the .class files (in their folder/package) or create a jar file with the classes. Then add that to the classpath of the project you want them to be used.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all what type of argument does ps.setDate() have and what type are the to_date, from_date at your database?

Also if you need to convert a String to a Date try this:

String sDate = 01/04/2009;  // 1st of April
String format = "dd/MM/yyyy"

SimpleDateFormat sdf = new SimpleDateFormat(format);
sdf.setLenient(false);

Date date = sdf.parse(sDate);

Check the API for more: SimpleDateFormat

peter_budo commented: Simple and effective solution +18
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well first of all you need to declare Scanner like this if you want to read from a file:

String fileName ="C:/MyFile.txt";  //myfile
      
      //Scanner scanner = new Scanner(fileName);

      Scanner scanner = new Scanner(new File(fileName));

With your way, I tried to do scanner.next() and it returned the fileName, meaning it returned the String you put at the constructor not the elements of the file.

Also in the while, you forgot to increment the cur value:

while(scanner.hasNextInt()) {
         int x = scanner.nextInt();
         temp[cur] = x;
      
         [B]cur++;[/B]
      }

I would suggest to add an extra check at the whill loop in case the file is too big:

while ( (scanner.hasNextInt()) && (cur<temp.length) ) {

Also at the for-loops it is best to use the length attributes. If you change the length of the array, you don't need to search and change the entire code for all the loops:

int i;
      for (i=0;i<temp.length;i++){