peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Check your school library for following books

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

It comes down to basics. Array of length 10 is array starting with object at position 0 and with last on position 9.
So considering you just run "i++" on 8 which will become 9. The termination expression "i<=toki.length" will check if "i" is smaller OR equal to array length. In this scenario it is still TRUE, therefore another increment and we land with "i=10".

Now you tell me what will be outcome of termination exception...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Because of your lazy approach here is lazy answer Head First Java

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Who came with that idea is idiot. Only reason to use Apache server would to have as top container for Java server/container and even then I would do it as separate installation not with preconfigured package for PHP (which WAMP/XAMP essentially is)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Hi javanator, your given solution solved my problem, you got the correct solutio for ClassNotFound Exception in the given scenario to connect Java with WAMP MySQL.
Thank you.:)

If you installed WAMP just because of that, then shame... Proper source allocation/linking is all what is need it.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

We may guide you if you post code what you made so far. Otherwise it would be handling over code to another lazy student. So show us what you got...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You can install Sun Java as explain in this thread

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You should better check what installation of Java you using because Ubuntu 10.04 doesn't come with Sun Java and this has to be add it manually.
Simple check

java -version
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Thread closed before another credit card signature spammer will find it like studentcredit dude.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Have look at google scholar, wii controllers been topic of many projects since they came out http://scholar.google.co.uk/scholar?hl=en&as_sdt=2000&q=wii+controller+connectivity

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This is how simple it goes

import java.util.ArrayList;

public class RandomNumber{
	
	public static void main(String[] args){
		int randomNumbers = 10;
		ArrayList<Integer> numbers = new ArrayList<Integer>();
		int number = (int)(Math.random() * randomNumbers);
		numbers.add(number);
		for(int i = 0; i < randomNumbers-1; i++){
			do{
				number = (int)(Math.random() * 10);
			}while(numbers.indexOf(number)!=-1);
			numbers.add(number);
		}
		for(Integer i: numbers){
			System.out.println(i);
		}
	}
}
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Check end of this tutorial to see how to generate random numbers http://java.sun.com/docs/books/tutorial/java/data/beyondmath.html

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You need to compare return from random function with some collection of previously provided numbers and check for duplicity. If a number already exists you want to call random function again, till you get number that does not exist in the collection.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry for delay, here is a working example
HelloMIDlet.java

package hello;

import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;

public class HelloMIDlet extends MIDlet{
  private Display display;

  public void startApp() {

        if(display == null){
            display = Display.getDisplay(this);
        }
        display.setCurrent(new MainScreen(this));
  }

  public void pauseApp(){}

    public void destroyApp(boolean unconditional){}

    public void close(){
        destroyApp(true);
        notifyDestroyed();
    }
}

and form view MainScreen.java

package hello;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import java.io.IOException;

public class MainScreen extends Form implements CommandListener, Runnable {
  private HelloMIDlet midlet;
  private Command exitCommand;
  private ImageItem im_item;
  private Image image1, image2;
  private String[] imgSrc = {"/res/r001.png", "/res/r012.png",
    "/res/r024.png", "/res/r033.png", "/res/r039.png", "/res/r048.png"};


  public MainScreen(HelloMIDlet midlet) {
    super("My Form");
    this.midlet = midlet;
    init();
  }

  private void init() {
    image1 = imageLoader(imgSrc[0]);
    im_item = new ImageItem("", image1, ImageItem.LAYOUT_CENTER, "");
    append(im_item);
    exitCommand = new Command("Exit", Command.EXIT, 0);
    addCommand(exitCommand);
    setCommandListener(this);
    Thread t = new Thread(this);
    t.start();
  }

  public void commandAction(Command c, Displayable d) {
    if (c == exitCommand) {
      midlet.close();
    }
  }

  private Image imageLoader(String src) {
    Image img = null;
    try {
      img = Image.createImage(src);
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    return img;
  }

  public void run() {
    try {
      Thread.sleep(3000);//set for 3 seconds
    }
    catch (InterruptedException e) {
      e.printStackTrace();
    }
    appendForm();
  }

  private void appendForm(){
    image2 = imageLoader(imgSrc[1]);
    ImageItem ii = new ImageItem("", image2, ImageItem.LAYOUT_CENTER, "");
    append(ii);
  }
}

PS: Try to keep image outside of Java package for better organization.

Software guy commented: Perfect Example for my Question +3
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@rasna this thread is almost 2 years old and there is no point to reopen it. Please create new thread, provide relevant coding and explain properly what sort of issues you are facing.

Thread closed!

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Java 3D API Tutorial and more if you google for it

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Looks like logic is not correct. I guess you are building form and appending images on build. What you need is build form with one image and display it, in same time set sleep thread which will then call method to append new image

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Them please mark thread as solved. Below last thread there is hyperlink "Mark this Thread as Solved"

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

However now you are getting error because your class "a" (You should really name it something meaningful) cannot find class "Banking"

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

In the class or the applet?

Looking on your code "EmmaDate" need it. Not sure about applet as there is no code

EDIT: LOL 3 replies in same time

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@DeadSoul
1. We want to people learn and not just copy and paste solutions, so next time please provide just basic guidance points and not whole solution.
2. Question was about "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" not about ODBC
3. Was there any request for GUI?

@tufzz good start not many people actually use command line and giving connector location like you did, they most often stick driver where ever they see on internet from wrong people.
As for connection string String sURL = "jdbc:mysql://studdb-mysql.fos.auckland.ac.nz/<DATABASE_NAME>"; can you elaborate what you doing? If you trying to connect to external database you need have your server configurated properly as most MySQL instalation run under "localhost".

Anyway command line compile from location of your java file keeping in mind you have JAR in same location

javac -classpath .;./mysql-connector-java-5.1.12-bin.jar DatabaseDriver.java

Command line execute

java -classpath .;./mysql-connector-java-5.1.12-bin.jar DatabaseDriver

Have fun ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry guys for inconvenience, posts moved as necessary. They will just sport new titles ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Please post stack trace and not only whatever left overs JVM throws at you

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Instead of printing custom messages use printStackTrace() and post it back here

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I think yesterday's Google I/O keynote proves my point even more about where the industry is heading.

Thank you for the new forum :).

And I though it would be thank you moderators for moving existing stories to this new forum section :(
But then it would be self-advertising :D

Hopefully soon I can start adding some small bits from Android development...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@Peter:

Did you try to ctrl-F5?

You right, it need it only cache clear ;)

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

This forum option still does not show in regular drop down. Wonder if it is so on purpose or dani forgot to include it in drop down...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Java Microedition doesn't provide tools to deal with this. Http connection here is not use for reading web site through browser but accessing raw data.
So either you use it only for simple server-client communication or develop JME mobile browser (if I may I would recommend to drop option 2 as JME is almost dead...).

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

isSelected() method inherited from AbstractButton

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

@Madhusudhan_Ram you failed to understand purpose of this forum. You may want to read this We only give homework help to those who show effort.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Okay, I see why you suggested to have an object: person, but i'm confused on the atttibutes & methods that I listed, were they also not right?

You will use these methods, but they had no direct relevance to person object.

Why don't you try to put in coding changes that I suggested on Person object (Person object will have no main method only parameters, constructor and some setter and getter methods). Then write a class, let call it TestPerson, that has main method, provides read and write method, validation method and makes use of Person object. In case of TestPerson skeleton of methods will do just fine, at the moment I'm interested only in Person class.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

and which shows the complete disconnect between what punters are taught in school and the real world...

Yes, but unfortunately there is really little we can do about it...
Few options open

  • write a book
  • take teaching position
  • try to establish connection between industry Java developers and academic to understand each other

However this went off topic.

Is there anything else student.09 you want to discuss?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

in fact it's impossible to "validate an email address" using just a check of its content.
Not only does it inevitably yield a lot of false positives, it will also yield false negatives as noone ever takes into account all possible protocols and variants.

What you say is correct in industry, above is just school assignment that is set to test student knowledge for working with strings.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Sorry here is correction

A UUID is a Universally Unique identifier. This is usually a very large number, typically 128 bits. UUIDs are generated using combination of unique items (such as the MAC address on an ethernet interface) and random elements (the clock ticks on the computer at time of number generation). The idea is that the probability of two numbers generated, anywhere in the world, at any time, is infinitesimally small.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

so far I have been able to put this much information together:

class: PERSON

attributes: lastName, emailAdd

methods: readFile, writeOutcome, validateFile

um are there going to be arrays?

arrays: validEmail, invalidEmail, validLastName, invalidLastName

NO this looks like bad structured application.

You want to have object person that has attribute last name and email, with methods to set and get values of these parameters. It is your program that will have methods to read & write plus validation. As for arrays, you better to use collections like ArrayList, List, Vector etc that can dynamically change size unlike array that has pre-terminated size

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Numbers of methods is irrelevant and it would vary from developer to developer. What they will have in common is:
- have way to read file
- store retrieved values
- evaluation of retrieved data
- writing data in files

So take it from here and think what you can do from here and which of above 4 steps can be decomposed further down

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

In PHP I have to submit a form and catch it via $_POST superglobal. I will then have to start session and so thing goes on and on. I was asking how does this differ in JSP? Are things the same or dramatic different?

Thanks

Fundamentally same:

  • servlet will use doGet() or doPost() (other methods are not used often)
  • create session
  • attach it to next forward/redirect servlet does
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

1-Iam writing a server code not a client code so Should I search for devices or this applies to client too?

Servers as always plays passive role. Server is set as discoverable and it is client that active player searching for service.

2-What do you mean by device ID I don't think that you mean UUID as it is reserved for a certain service isn't it? or you mean Browse Group UUID???

Yes, I meant UUID that is mobile "MAC" address of devices.

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

There is no single old import among the present imports they are all present in many codes used in your book and the way of writing codes by defining StreamConnection and StreamConnectionNotifier is used everywhere on the internet...If you mean Rocococoft and atinav I found posts which might be useful to you too that I donot need a third party classes to run this on mobile so the problem now is in the btspp again

What I was saying is not that you have some "old imports" but that you are trying to "import old packages" that are not used any more. And as I said before your connection string "btspp" is wrong because you either have to know device id or you have to first search for available devices and get their ids so you can build your connection string

The link is from Nokia Forum:
http://discussion.forum.nokia.com/forum/showthread.php?p=689118
And by the by they are using the same book u refuse and this was @2009 i.e. only one year ago

If you have read whole tread carefully you would have found that they think, same as me, that code is old and crap

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster
peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

That books Bluetooth for Java is too old and uses old packages that are not available any more. Get something newer. Either Beginning J2ME as I suggested in my previous post or the latest copy of Kicking butt with MIDP and MSA

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

I would be interested to know where you did get that URL for bluetooth from?
As the error message protocol doesn't exists as you provided malformed URL. Read this on how URL should be correctly formatted and if you wish to connect to a device either find his ID or use discovery to find any bluetooth devices in proximity. Here is limited preview of chapter Bluetooth and Obex from Beginning J2ME - From Novice to Professional that will get you started

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

Why didn't you post problem description or any error you getting? Why you expecting people to copy and paste your code, debug it to find issues?

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

First post here explains how to install Java under Windows or Ubuntu. Here you can find simple "Hello World!" for Microsoft Windows or "Hello World!" for Solaris OS and Linux for command line

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

If you want database to embedded why don't you use serverless DB like SQLite, HSQLDB or similar instead of MySQL that would become pre-requirement for your application to be able run on different machine.

Also mentioning connection pool name, some relevant coding and exact error you getting is always helpful (you should know that you are not first time poster her ;) )

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

what it is saying is that you did not closed all open brackets. In your case you closed your inner class DrawPanel inside Connect4View but never actually closed Connect4View that is encapsulating the inner class. Just add "}" at the end of program and you done.

PS: Any basic IDE would help with this. Just click/highlight opening bracket to see if you have closing one...

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster

You may start with this

peter_budo 2,532 Code tags enforcer Team Colleague Featured Poster