javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If it does not contain pure numbers like this:

1 2 3 4
5 6 7 ......

then the file contains a serialized object.

Can you post part of the file's content?
Who gave you this file?
Where you told how it was created?
What object does it have inside?

When you will learn how to create objects, if you have them implement the java.io.Serializable interface, you can save into files and read them like this:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/ObjectInputStream.html
http://java.sun.com/j2se/1.5.0/docs/api/java/io/ObjectOutputStream.html

try {
        FileInputStream fis = new FileInputStream("filename");
        ObjectInputStream ois = new ObjectInputStream(fis);
   
        Object obj = ois.readObject();

         // OR IN YOUR CASE
         // int [][] array = (int [][])ois.readObject();

        ois.close();
} catch (Exception e) {
  System.out.println("Error: "+e.getMessage());
}

But first you need to answer me the above questions.
What kind of file do you have?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If the data are inside a file then your problem is not with 2D arrays, but with reading a file.
Anyway, in what format are the data inside the file?
Like this for example?

File:

10 20 ..
8 9 ..
-5
.
.

Is your problem reading the data from the file? Have you been asked to read the file inside an array and then print the data or take them directly from the file. The latter will not require a 2D array. For further info about reading files check tutorials about the Scanner class in this forum or other places on the internet


Also about the 2D arrays, and assuming that you are familiar with 1D arrays:
2D arrays don't exist in java. What java actually does in order to "represent" 2D arrays is have a 1D array and put inside it other arrays:

This simple example:

String [][] sArray = new String[3][2];

sArray[0][0] = "1";
.... 
sArray[2][1] = "6";

Is like saying that sArray has length 3, and each of its elements is an array of length 2:

String [][] array = new String[3][];

array[0] = new String[2];
array[1] = new String[2];
array[2] = new String[2];

array[0][0] = "1";
....
array[2][1] = "6";

Meaning that 2D arrays in java don't need to be rectangular. You can have arrays like this:

1 9
2 -4 6 5
1

int [][] ar …
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I assume that the file D:\\A.txt has integers inside it. Can post part of the contents of that file.

Also this is how it is declared with the public first:

public static void main(String[] args) {

}

But I am surprised that you said that it compiles.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I am sorry for posting to this thread since I don't have anything new to add but I can't help to notice that you both have been down voted.
Congratulations.
Yet another post where someone, anonymous, decided for no reason and explanation, that an interesting question and a good answer should be down voted.

Looks like that the voting system is being repeatedly abused

BestJewSinceJC commented: Amen. +4
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can you post the code where you add rows to the table or you change their values?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi ordi. You are new here so you must learn that you shouldn't give the code for others people assignments. This is not that kind of forum.

When someone's post their assignment and nothing more don't give the complete solution. It violates the rules.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Are you having problems compiling or running?
Because your program seems to be good to be compiled, but can you run it?
If not how are you trying to run it? With what command? And from where you run that command. Are you at the folder where the .class files where generated?

If it doesn't compile what errors do you get?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi All
I have a problem.

I have been having some problems with my PC so I called technical support and they suggested that I should re install the drivers. I entered the CD with the Vista Drivers, followed the instructions after a while a black screen appears with this:

Bad or missing Command Interpreter
Enter the full shell command line:
command.com /P /E:256

What should I do? It is stack there?

Also the CD label said:
P5Q PRO/P5Q Series
Intel P45 Chipset Support DVD Rev.374.04

Thanks

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

org.apache.catalina.util.DefaultAnnotationProcessor cannot be cast to org.apache.AnnotationProcessor

That is your problem as far as I can see. You are trying to cast an object to another that cannot be done.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What errors do you get?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

So there is the problem. What did you try to fix it?

I would like to agree with Ezzaral and add some more comments.
In previous post you have been told the location of the error and asked to post relevant code indicating where the line was.
Then you posted your entire code, leaving us to search where in the world was that line with the error, even though you've been told which line was that and to post only that.

Also please next time to read the errors that you get. They are followed by very explanatory descriptions:

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:868)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3340)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1238)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2743)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at frame.Admin.<init>(Admin.java:39)

Are you sure that you are using the right username, password? Try to connect to the mysql command prompt using that username and password that you have in your code:

con=DriverManager.getConnection(url,"root","389");

Is it working? What combination did you use to login? Or you have set it so it won't need a password,
If you do not want to share that information it is understandable.
Your next move would be to check the API for the class: java.sql.DriverManager and check the description of the getConnection methods.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Looking at the stack trace, because it is very difficult for you to just read the error messages and you need someone else to do this for you,
I saw this:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at frame.Admin.jButton8ActionPerformed(Admin.java:360)

You have a NullPointerException at the Admin.java file at line 360

You are using something which is null, something which is not initialized. Try and see what is going on around that line and then if you can't fix it, post the code around that line, indicating which line it is

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The code that I saw runs ok. All you need to do is add the changes I recommended and proceed with the rest of the choices.

For the view car list,
just have a for loop (use the size() method of the CarList in order to see how many cars the list has)
then iterate the list and use the get method to take each car.
In the for loop, print the values of the attributes of the car

public class Car {
String make = null;
String model = null;
String year = null;
  
public Car(String make, String model, String year) {
   this.make = make;
   this.model = model;
   this.year = year;
}

// ADD GET/SET METHODS
// example:
public void setMake(String make) {
   this.make = make;
}
public String getMake() {
   return this.make;
}
// USE THE GET METHOD TO GET THE VALUE AND PRINT IT.
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What problems are you having? Your question is very vague. You just posted some unfinished code without any further explanation. Also what you did with the Car class is not the right way to do things:

public class Car {
String make = null;
String model = null;
String year = null;
  
public Car(String make, String model, String year) {
   this.make = make;
   this.model = model;
   this.year = year;
}

// ADD GET/SET METHODS
}
class CarList {

private List<Car> list = new ArrayList<Car>();

public void addCar(Car c) {
   list.add(c);
}

public int size() {
  return list.size();
}

public Car getCar(int i) {
  return list.get(i);
}

}
class AddEntry {
public static void main(String[] args) {
CarList carlist = new CarList();
Scanner s = new Scanner(System.in);
int choice;

System.out.println("\t Welcome to the car  ");

do {
System.out.println("Make a selection ");
System.out.println("1. Add a Car ");
System.out.println("2. View car list ");
System.out.println("3. Delete a car ");
System.out.println("4. Quit ");

System.out.print("Enter your choice plz: ");
choice = s.nextInt();
s.nextLine(); // Discard the rest of the line

if (choice == 1) {
   // use the Scanner to read the data from the keyboard and add the Car
  System.out.print("Enter the make");
   String make = s.nextLine();
   ..
   ..

    carlist.add( new Car(make, ..., ...) );
}
} while (choice != 4);

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

Check the forum for the usage of the class Scanner. It is used for reading from the keyboard.

Operator: '%'
Assuming: A = b*c + d
Then:
A%b = d
A%c = d

Small example:

int a1 = 10;
int a2 = 9;

int r1 = a1%2;
int r2 = a2%2;

Don't expect a complete solution. You have many small problems. Start by writing code for each one of them separately and post the code you have written. Do not flood this thread with unfinished code from all your questions. Try to solve one by one. Post code for one problem. Once you solve it, post the next

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

you didn't declared the disposition, temperament, and colour variables

Yes that is right. You weren't suppose to just copy my example, but try to understand it.
Since I declared the name and age and used them at the constructor, when you added the rest of the variable you should have followed the same pattern of declaring the rest of the variables as well creating get/set methods as explained.

Also you are using these variables and you do not declare them: disposition, temperament and human. They all represent if his is happy or not.
So decide a name for that characteristic and do what is done for the other variables.

Also don't use the '==' to compare String, but this:

if (temperament.equals("happy")) {

}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
public class Human {
  private String name = null;
  private int age = 0;
// ....

// constructor
// these arguments are not the same as the ones declared above
public Human(String name, int age, String  colour, String  temperament) {
     // use the set methods to set the values
}

public Human(String name) {
   // do what the exercise describes for this constructor
}

// get method
public String getName() {
    return name;
}

// set method
public void setName(String name) {
   this.name = name;
}
// the name argument is the argument of the method
// this.name is the global class variable you have declared at the beginning of your class
// that is how you distinguish them 

}

If you did something like this:

public void setName(String na) {
   name = na;
}

This time the 'name' variable is the global class variable since there is no other 'name' variable declared locally

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

am i suppose to pass the label fields as argument or the text fields??

What are the arguments of the method?

And on a more personal note, and don't take this the wrong way but it is true and lots of people will agree with me:
The title of this thread is "Rmi database insert". And from the code I think you are trying to call some remote method: CustomerInformationServer.insertDetails.
Now it is clear that you lack the very basic: Calling methods. You don't even know how to call a single method and pass arguments to it and you are trying to do something like that? Shouldn't you first learn the basics and then do more complex stuff?

And if you tell me that you wrote that code and you know how to call methods, because it is true, you do that in your code, I will say that you need a lot more practice, because I can assure you: the error you get has nothing to do with RMI. It has to do with calling a single method with the right arguments,which is basic java.

The error tells you exactly what arguments the method takes, as some of the initial posts say, and you have been informed that you are calling the method with the wrong arguments.

So now you ask, if you should pass the label or the text fields. It is clear that, even though you wrote that entire code, which …

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The class should have as a field an ArrayList of T. Write a public method named add, which accepts a parameter of type T. When an argument is passed to the method, it is added to the ArrayList.

Where in your code did you implement that requirement?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Then you can have the other 2 panel's constructors have as arguments the other panel:

class FirstPanel extends JPanel {
  private SecondPanel second;

   public FirstPanel(SecondPanel second) {
      this.second = second;
  }
}

Do the same for the SecondPanel. Then the components of those panels (combo box, JList) can either be public or have get methods, so you can access them and modify their values

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Are the 2 panels declared in the same class. I mean are all your components visible in the same class. If yes, then:

Check the API for JList and see what type of listeners does it take. There should be a method add..listener... Check if there is a method in that interface that the description says that is executed when an item is selected at the list. Then have your Main GUI class implement that interface and add that listener to the JList:

class MainGUI extends JFrame implements ListenerInterface {
  

...
list.add...Listener(this);
}

Then when you implement that method check the API for the argument, and try toy get the selected item. When you do display that item to the combo box by using its methods.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

My previous post already states what to use as a delimiter.

Also what are the methods you want to use of that class that cannot be done with the split method? I am not suggesting that using the StringTokenizer would be wrong. I was just asking

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

As I said:

You are not calling it with the right arguments. Check the declaration and call it with the right arguments

When you declare a method you need to call it with the number and type of arguments that was declared.

tactfulsaint commented: thanks for all your help man. +3
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well as you have noticed the command given, brakes the input into smaller pieces depending on the argument:

StringTokenizer st = new StringTokenizer("I born on 21.02.1995. So, now my age is 15.", ".");

So all you have to do is figure out what to use in order to break the above sentence in two:

StringTokenizer st = new StringTokenizer("[B]I born on 21.02.1995[/B]. [B]So, now my age is 15.[/B]", "??????");

Notice that the above are not separated by a '.' but by a '. '
If the above is unique in your sentence then you can use that.

Also it is better to use the split method from now on:

String s = "I born on 21.02.1995. So, now my age is 15.";
String [] tokens = s.split(" ");
for (int i=0;i<tokens.length;i++) {
   System.out.println(tokens[i]);
}

You can use the above and in order to get these 2 sentences:

I born on 21.02.1995.
So, now my age is 15.

You can concatenate the first elements of the array into 1 String and then the rest into the other.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The letCarPass will do what is described. In the class you will have private attributes: cash, cars, violators. These will be returned by the respective get methods.
Whenever the letCarPass method is called depending on the arguments and the description provided you will increase accordingly the above fields: cash, cars, violators

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well how do you run the command and from what folder? Maybe you are running it from a folder that doesn't see the javac command.
Where have you installed java?

Do you have a similar path like that?
C:\Program Files\Java\jdk1.5.0_17\bin

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do you have an IDE installed. (JCreator, NetBeans, eclipse) ?
Try compiling and running a small class and see what happens

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You said that my link's installation was successful. So why try to install another jdk?

Also try to open a command prompt and execute this command:
java -version

I got back this:

java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build 14.2-b01, mixed mode, sharing)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The link is correct. I don't know what the problem is.

Have you tried this link:
http://www.java.com/en/

I don't know if it is going to help you, but you can try.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What is the service pack of your windows and can you post the link you used for downloading?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Even though it is not a problem, you don't need to call the getSelectedCol, since you don't use it. Also it is not necessary to call so many times the getSelectedRow. You call it once and you get the row. So you can use that.

Also if the user clicks the "Delete" button without selecting a row, it will return -1, as you have noticed from your previous exception. You need to handle that.

int row = visittable.getSelectedRow();
if (row==-1) {
  // no row selected
} else {
   if want to delete the selected row {
     // USING YOUR CODE: 
     String idnum = (String) visittable.getModel().getValueAt(row, 1);

// first delete from database
                    VisitMethods delmthd  = new VisitMethods();
                   delmthd.delete(idnum);

// if the above executes, then you can safely remove it from the table
      model.removeRow(row);                            

model.fireTableRowsDeleted(0,row+1);
                   refreshwdw();
  }
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

USE CODE TAGS. And you declare your method with arguments and you are calling it without.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Okay? I have no idea why anyone would want to "vote down" that post, but ......

To each his/her own, I guess. What about it was disagreed with would interest me though.

Another victim of the anonymous down voting, raises the issues that we have so often discussed regarding that matter in other threads

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I have been busy, so I could not reply back. Even though your responses haven't been most helpful.

You initially posted 4 values: 0,1,-1,1 without explaining anything. Then again you posted 4 System.out.printlns. Ok I know that this is the command you used , but from where did you call those. Before calling that method you created, after, inside?
Also that method takes 2 arguments and you posted 4 values. The idea is to print the arguments of the method that is giving you the error: getValueAt.
But from the code you wrote that method takes as arguments the row, col which as you said have values 0,1. So you shouldn't be getting ArrayIndexOutOfBoundsException.

So try to post the whole code. Not just some unrelated System.out.printlns. The one that calls the method and prints the values.
Print only the arguments of the method that gives you the exception just before you call it with those arguments.

Because if you use the getSelectedRow/Col that returned -1, of course you would get that exception. But you posted 4 values without saying which of these 2 you used.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You declared the method like this:
Scan1(int[] num1)
And you are calling it like this:
Scan1()
Something is missing

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Who is writing to file? Maybe you don't need to read the file, but the lines that are written by the process.
But if the files closes and then someone else tries to append something else to that file with a new writer then if you don't remember what was written by the first writer then you would have to read the file.

Perhaps if you explain your problem better you would get a better answer, but checking the RandomAccessFile class might be a good place to start.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Correct me if I'm wrong, but aren't data in the table first populated by servlet?
If it so then you have some unique IDs you can reuse for creating links with call for servlet plus additional parameter which in this case would be some unique ID, for example book shop would use ISBN as this unique and hyperlink would be as "www.bookshop.com/ServletCall.jsp&itemId=1234"

I am sorry for replying to this, but shouldn't it be like this:
"www.bookshop.com/ServletCall.jsp?itemId=1234"
instead of a '&'

peter_budo commented: Well spotted. Thank you! +12
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You are calling a constructor that does not exist. It is like calling a method with the wrong number or arguments. You haven't declared that kind of constructor:

Student s1 = new Student("kamal", "kandy", "5678")

Also if you paid attention to the errors that you get, you should be able to figure that on your own.

Also it would be better to rename the method getdetails to toString.

It is inherited from the Object class and is called automatically when you do this:

Student s1 = new Student("kamal", "kandy", "5678");
System.out.println(s1);

Try printing this:
System.out.println(s1) without defining it and then create that method (toString) and try again.

scratchwiz commented: thanks... +0
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

As explained in my previous post: START a new thread. Have you no interest to my suggestions?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have a while loop that stops when the user enters a specific character.
Then inside the loop read 1 input from the keyboard and compare that with the previous one. If they are the same then you have duplicate. Remember at the end of the loop you will need to replace the value of the old value with the current value, so at the next loop the current value would be treated as the old one to compare.

Also start a new thread, if you have any more questions.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The method takes 2 arguments. Row, Col index. What are those 4 values?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Well, what do you get from printing the arguments? Why do they have those values? What are your conclusions? Asking your self those questions will help you find the answer.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Please use code tags and try to point us to the part of the code you are having problems with

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have you tried to print the arguments you are using to that method in order to see why you get that error?

You know it is very easy to debug on your own. We are here to help you, but don't just post every error you get and expect others to solve it so you can post the next error and so on and so on. What actions did you took to understand the above error. Have you given any effort apart from posting the error here and waiting.

The above trick of printing the arguments was very easy to think on your own. Students that program for the very first time use that, not someone that wants to be hired as a professional.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Also what you want will not be in a separate method but you will submit the form "towards" the servlet when you click the button and execute the code inside the toGet method of the servlet

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I found the question confusing and rather vague in order to give a complete answer.
My point was, that since it was the developer's decision not to have multiple inheritance, perhaps you would have gotten a better answer if you had searched some of the documentations of java

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Because that is how it was written. There is no why. Maybe you should rephrase your question

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

First of all if you look at the API of the classes: ObjectOutputStream, ObjectInputStream, you will find examples on how to save and read objects. Use those.

Also what type is the itemInventory and does it implement the java.io.Serializable interface?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You intiolized the String object 's' inside a local method called...initializeStuff() ...... But 's' is instance variable...so after completing the execution of the this local variable the 's' will hove nothing...in the sence "Null"....if u use the S.O.P statement inside the initializeStuff() method, it will work.....and prints 3...
so assign a value to 's' variable where u have defined it....then it wil give answer to you.....
otherwise it will be an error.........
thank you

Again, you responded to a VERY old thread were the answer you given has already been provided by others, without contributing anything

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

how to see your coding? i couldn't find...

This thread has a few suggestions. If you still have problems then START a new thread, with specific questions followed with what you have done so far