~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Lol sorry, I'm a little confused. What's "you/jar/one.jar" or is that just a code? Is that the libray, in my case, bouncycastle (the library is a jar file)? And if so, does that mean I have to put the bouncy castle in the parent folder of "test" and "pkg"?

That was just a sample I posted. You can specify any number of JAR's in a similar fashion. Also, you don't need to move around your JAR's; just put the path where your Bouncy castle JAR lies and you should be good to go.

java -cp .;c:/jars/bouncy.jar;c:/jumping/jack.jar pkg.Main
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
java -cp .;your/jar/one.jar;your/jar/two.jar pkg.MainClass

Run this from the directory where you have all your compiled classes. For e.g. if your class package is "test.pkg", then run it from the folder which is the parent folder of the "test" folder which in turn in the parent folder of the "pkg" folder which contains your main class.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Make sure you have the required libraries on your runtime classpath. Are you packaging your app as a JAR file or as class files? If you are running your app as a packaged JAR file make sure you have all the required dependencies present in the JAR file. If you are running a class file make sure you specify the -cp or -classpath argument to the Java process.

Edit: I just noticed you have created a lot of posts over the past few days but not marked them as solved. If your problem has been solved, please mark your posts as solved so that it might be easier for someone with the same query to find a solution.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

i know what an interface is. but i dont understand what the use of connecting the objective reference to the interface method and then use it to implement..

Take a look at the Strategy Pattern. A bit more practical explanation.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAIK, you have two options:

  • Use an alternative Java serialization implementation like Jboss Serialization which AFAIK doesn't require your classes to implement Serializable or Externalizable
  • In case you are concerned more about interoperability than speed, use something along the lines of Xstream or Protobuf
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Two issues I see with the code you posted:
- What is the point of setting the PreparedStatement parameters *after* adding a batch?
- For executing a batch use `executeBatch` instead of `executeUpdate`

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
BestJewSinceJC commented: very helpful +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Assuming you are creating a chat application, there are at least two ways of going about this one:
* Create a language/platform independent protocol for your chat. This has the advantage that a client written in any language can communicate with your server, it need not always be a Java client. E.g. XMPP (specifically aimed at RTC)
* Write and read Java objects, as simple as it gets. The practical drawback being you can only use Java clients to communicate with your server. Technically, you can use any language provided it can serialize/deserialize its object as per the Java serialization specification but we wouldn't go there.

Regarding the common classes: one way of tackling this problem is to create a separate project which contains your VO's and interfaces. The JAR exported from this project would be used by your server application along with being shipped to the client. Again, the catch here being that updating your interfaces/VO's might require that you ship the updated JAR to your client so that it can be operational and still communicate with the updated server.

Also, to ensure that simple updates to value objects (adding helper methods) don't break your existing clients, *always* provide an explicit `serialVersionUID` for your serializable classes. If you don't, an automatic one is generated for you. Simple structural changes might cause a new serialVersionUID to be generated which isn't desirable.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

From this site which is a *very* reliable source:

Oracle has changed the naming for all sun certifications,to fit existing oracle certification names,effective September 1st

Note that this is just a name change,nothing will change regarding the certifications themselves

Naming of the certifications before and after the change


for example SCJP 6 will be called "Oracle Certified Professional, Java SE 6 Programmer" from now on

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Agreed; Java EE would be a much better and official name. Or if not that then maybe another "Java" inside the "Web Development" forums.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Read the article presented at the official Ant site, especially the section which states:

# Make sure the class that implements your task is in the classpath when starting Ant.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Database Design certainly doesn't seem like a catch-all term. Come to think of it, having a single "Databases" forum for some time would help us evaluate whether we really do need a separate forum for each specific database.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Unfortunately no. The simple reason being that for me a news aggregator site like reddit/digg/hackernews does a far better job at presenting <insert-your-interest-here> news story than a single site. Plus most of the news stories here are more "tech" oriented (gadgets, gizmos etc.) than being "developer" oriented (a new programming language, blog post about concurrency issues in Java etc.). Also, the lack of discussion on articles coupled with limited content doesn't make Daniweb a one-stop for a news story, at least for me. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

His issue is that the hyperlink created by vBulletin if a user posts a link without using the URL bbcode is broken for wikipedia article links which end with a ).

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A better option would be for you to configure the same in your web.xml file so that:
* changes can be applied to all the JSP files with a single configuration
* changing the configuration amounts to just changing the web.xml file and not each and every JSP

Also, if this thread has served your purpose, please mark it as solved using the "Mark this thread as solved" link above the quick reply box.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A null could be unexpected. I think an empty array would be better:

If you look at the Java process invocation posted in the first post;

java -jar ./jars/myJar.jar

No command line arguments passed so no fear of running into NPE.

But then again, that was just an example to be fixed by OP as he sees fits. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your suggestion does not take into consideration idiotic answers, forum trolls etc. Plus, idiots have a knack of posting on "popular"/"useful" threads which makes down-voting it something which is against the spirit of voting, so yeah... ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> At a certain moment my code makes this call:

There is no need to spawn a separate process for this; just make sure that the JAR is in your classpath and invoke the `main` method of the class which has that method. E.g.

import your.jar.pkg.MainClass;

public class Test {
  public static void main(final String[] args) {
    MainClass.main(null);
    // The above would same as your Runtime call given that the
    // main class for that JAR file is MainClass.
  }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Can I say:"the memory size for boolean varies on different computer platform"?

No, when someone asks you the size of a boolean, you state exactly what is stated in the JVM spec, no more, no less. This is because saying that "it varies on different platforms" would be more or less claiming that the change in platform would result in a change in the size of a boolean which isn't true.

Different VM implementations carry out optimizations which might result in a boolean occupying anywhere from 1 byte to 4 bytes (in case of a padding gone bad). I did read somewhere that some VM implementations translate a boolean to an int when writing out the class file. Not to mention that things get even more complicated when we consider 32/64 bit CPU with 32/64 bit OS combination. :-)

This is exactly the reason why people prefer using BitSet instead of an array of booleans; less overhead since each true/false bit is represented as a single bit always in BitSets.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Instead of using Runtime class, just include the given JAR in your application and use the relevant method of the relevant class.

package your.pkg;

import com.salesforce.lexiloader.security.EncryptionUtil;

class YourClass {
  public static void main(final String[] args) {
    byte[] encrypted = EncryptionUtil.encrypt(bytes);
  }
}

This of course assumes that there is a utility method in EncryptionUtil which takes in a sequence of bytes and encrypts them.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are of course welcome; good luck with your project. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A downcast is not what you need. Why? Because:

int i = (int)123.123; // 123
i = (int)123.223; // 123
i = (int)123.999; // 123

See the problem?

> double [][] array = new double [(int)row] [(int)col];

This will effectively declare a `double` array of dimensions `row x col` for *each* line read and then effectively discard it. You never save the actual value which you read.

All in all, the approach is flawed on many levels; what is required here is for you to jot down a plain text algorithm and trasnlate it to Java rather than diving head first into code. Reading the introductory Java language tutorials might help the cause here.

Begin with:
- Read a line from the text file and split the contents into a double pair
- Create a new Point class object for the double pair which will hold the x & y coordinates for a given point
- Add the newly created object to a List
- and so on....

You need to write down the "actual" problem statement here rather than what you make of the problem statement. That might help the members here in helping you better.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Google for "jboss download" and you should be good to go.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The code snippet works out well for me. For which set of data are you getting the loss of precision error? Why would storing a double inside a double variable cause precision loss? The only problem I see is your using double as an array index, which you can't. Why would you want to use a parsed double as an index to your array. I'm not sure what you are trying to achieve here...

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The runtime error thrown is pretty clear here; you are trying to parse the string "0.0 0.0" as an integer which won't work for obvious reasons and hencefails. Here is something you should attempt, one step at a time:

  • Read a single line from a file, print that line and verify if the lines are being read properly
  • Split the line on a whitespace character; a space in your case
  • Print out both the tokens and verify their value; both tokens should be valid "float" strings i.e. of the format X.Y

Tackle the problem in steps; first try out the parsing part for a hardcoded string. E.g.

String str = "0.0 0.0";
String[] splits = str.split("\\s");
// parse the first part as float; do the same with the second part
// print out the results and verify it
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

As already noted, you can't use the 'new' expression to create a new object at runtime given the way generics are implemented in Java. IMO, the cleanest (type-safe without any warning) approach you can come across can be achieved by passing in the class of the object you have to create. E.g.

private static <T> T addToList(List<T> list, Class<T> klass) {
    T t = null;
    try {
        t = klass.newInstance();
        list.add(t);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return t;
}

But then again, I personally think that having a method given the arbitrary responsibility of creating objects and inserting into Lists is a bit off. Any "practical" scenario you have in mind which requires you to have true generics?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Every example I've seen, the stream has to be flushed, but I don't know why

Some implementations of the OutputStream/Writer (e.g. BufferedWriter) buffer the data written to them and write it to the underlying actual stream only when the buffer is full. This is so as to avoid doing IO for each and every `write` call made and improve performance (IO is typically magnitudes slower than CPU bound operations). `flush` forces the implementation to write the data which it has buffered to the underlying stream.

Read the section 4.1.1 of this document.
http://java.sun.com/docs/books/performance/1st_edition/html/JPIOPerformance.fm.html

Also, as far as your question is concerned, if you are anyways writing objects, instead of owning the headache of mapping values to their respective variables, write out a single object. For e.g. if you want to send across a long value named phoneNumber, a string value named 'name', instead of doing something like:

oos.write("name"); oos.write("string"); oos.write(yourName);
oos.write("phone"); oos.write("long"); oos.write(longValue);

prefer something like this:

Person p = new Person(yourName, longValue);
oos.write(p);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Can anyone give me an idea on how to insert multiple record into a database.

Search for "Batch insert JDBC". Links which might interest you:
http://www.java2s.com/Code/Java/Database-SQL-JDBC/BatchUpdateInsert.htm
http://www.jguru.com/faq/view.jsp?EID=5079

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The presentation by the student as their own work of a body of material (written, visual or oral) which is wholly or partially the work of another

And who would be the "another" here? As long as you can prove that this Daniweb account actually belongs to you, it really shouldn't be a problem. It's not as if you won't be given a chance to prove your innocence.

BUT I am just requesting the mod/admin to remove the "CODE" from the thread which I've posted here and not the thread/post itself.

You do realize that it would render the thread useless, right? Or to put it another way, would you have been able to resolve the issue without posting code snippets?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

On behalf of the moderators here I think I've already given a fairly good reply to your query via PM as to "why" we don't delete threads on user request. Unfortunately, creating a thread in the Community Feedback section won't change it since rules are rules which have to be followed by mods and admins alike. If you *still* are unconvinced, you can get in touch with the site owner "cscgal" though I'm pretty sure that won't change a thing.


BTW, I hope your TA understands the situation here and you get the credit which you deserve for completing the assignment on your own.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That's a pretty vague description you've got there; *what* sort of problems? Please ask specific questions so that people can render specific help.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Thread closed to prevent bashing of someone who has already apologized. Peace. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Oh wait, I guess I remember that thread. Wasn't it the one having the contents same as this thread for which you had given a neg rep? It was deleted since it was a dupe, which kinda explains why you couldn't find it. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What was that thread about? Thread moving / deletion as duplicate is quite frequent around these parts so unless you can remember the contents of the thread or its context, not much can be done. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAIK, you can neither check for the up/down votes given by you nor for the reputation awarded to other members. A real pity, I know, but... :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Not exactly; the "const" of C++ has much more complicated usage than the "final" keyword of Java. More about "const".

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

SQLiteJDBC not good enough? Also, if you are aiming for embedded databases, I'd recommend pure Java ones like H2 & Derby. Both have a fully JDBC compliant type 4 (pure java) database driver.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Please do not, I repeat, do not link to any roseindia material. These guys are content thieves and more concerned about driving traffic to their site than imparting knowledge; a bad sign indeed. BTW, the original article is here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Normal users can't access Area 51 threads so the first link won't work for the OP; just thought would point this out.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Could anyone please tell how to set the path of the properties file, so that I don't need to specify the full path when reading it.

Specify it relative to the class which would be using it or relative to your project package hierarchy.

Relative to your class: Ensure that the properties file is present in the same package as the class trying to load the properties file. Then do something like:

Properties props = new Properties();
props.load(getClass().getResourceAsStream("test.properties"));

Relative to your package hierarchy: Create a separate package for keeping your properties configuration e.g. test.config. Now to load your properties file from any class, use:

Properties props = new Properties();
props.load(getClass().getClassLoader().
  getResourceAsStream("test/config/test.properties"));

Both these methods would almost always work irrespective of the OS which you are distributing your JAR to since the paths are relative to the class/working directory. Of course, the second method has the advantage of the properties files being reused across classes without altering the code.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You always require the fully qualified class name when referring to your class. Try something like:

c:\jcreator>java uniKEY.myLoader
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Your class 'myUI' creates a new 'myFunctions' object and your class 'myFuntions' creates a new 'myUI' object resulting in a never ending loop and hence the program running out of stack space. You need to decide which one comes first, 'myUI' or 'myFunctions' although logically it should be the UI class which gets created first which in turn instantiates the helper 'myFunctions' class object.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Before passing in the File object to the ImageIO#read method, print out its absolute path (File#getAbsolutePath)and verify whether it is the same as the path where you have stored your images.

Edit: Oops, didn't see Norm1's reply. But yes, print out the full path using the getAbsolutePath()

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Search the codebase for "new BookDBAO(" ? But ideally, since you are retrieving the DAO from teh servlet context, the instantiation should have happened in the class which ServletContextListener. Look into your web.xml if you have any listener tags and search in those classes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The errors are exactly what they say;

java.sql.SQLSyntaxErrorException: Syntax error: Encountered "cascade

It has failed to recognize 'cascade' keyword and hence the error. Since an error was encountered, the deletion of VENDOR table could not be completed. Also make sure that you delete the dependent tables first and then the table which refers to the dependents.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You still haven't answered the question "Where are you initializing the `_myFObj` object"?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Where are you initializing the `_myFObj` object? If the root exception cause is `_myFObj.loadDB();` throwing an exception, then it's pretty clear that `_myFObj` is NULL.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It seems that your DB structure is already configured and the build script is seemingly executing the same thing again hence the exception. You have two options:
1. make sure the db structure is torn down after a single test run so that the configuration scripts which run again can start with a clean slate
2. make sure that the db configuration scripts are not fired if the db is already setup

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

SOS, I have learned a lot from your poster. The answers are highly appreciated.

You are welcome. Please make sure you mark the thread as solved if your queries have been answered.

Also, it's "post" and not "poster". "Poster" is someone who makes the "post". :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You have a typo there; it is intValue and not intVlaue.