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

>Would Ruby be a good choice?

Yes, given that it's not just another scripting language but a fun language which *has* an enterprise standing. Ruby seems to be living up to its name of a "fun programming language". So IMO, Ruby and Clojure if you are going for dynamic programming languages and Scala[used at Twitter] and Haskell if you are going for a static, strongly typed language. Also, a stack based language like Factor would surely entertain you by changing the way you look at programming.

Also I tend to agree with darkagn that there is no ideal language. Some language might be able to do X sort of things in a small amount of code but require a lot of boiler plate code when doing Y. Like they say, the more tools in your toolbox, the merrier.

>Bestjew has taken this tread in a totally different direction

His post was on topic though and certainly didn't warrant a rep comment like "that guy was just a ****". If you find something annoying or wrong or off-topic, there is always a flag bad post button provided for that, no back seat moderation please. Consider this as your first warning; refer to the forum rules for details.

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

>it successfully got compiled but did run and gave the following
>errors!!!!

This is no longer a problem with your classpath setting which you were initially facing. Since it's an IOException, there might have been a lot of things going wrong here like the database not properly set to listen to connections etc. It would be kinda difficult to come up with a solution for us; do a web search for the given exception "Io exception: Got minus one from a read call" and check out the suggestions given there.

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

So, you were expecting a MySQL Driver class in ojdbc14.jar? How about looking for that class in mysql-connector-java.jar file? ;-)

peter_budo commented: Well spotted +22
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>This is getting interesting.

I don't think so. :-)

Post the entire command you are using as it is.

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

C:\Test>java -cp .;ojdbc14.jar OracleConnect

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

>java OracleConnect(name of my file)

Read my previous reply; just typing the class name won't do; you have to set the classpath.

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

Specify your classpath using backslashes and not forward slashes. Also, it would be better if you first tried this thing out by creating a new folder test and placing your class file along with the JAR file in that directory.

c:\Test>java -cp your-oracle-jar-name.jar YourClassName
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If memory serves me right, this is a known bug wherein if the dimensions of the image exceed certain pixels, the uploading fails and the upload window goes blank.

Edit: Aha, I think I found the link. Read the sixth paragraph.

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

Read the Javadocs of the classes ResultSetMetaData and DatabaseMetaData for more details regarding your database/table etc. A simple web search for these classes might give you sample snippets on how to go about using them.

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

This thread has gone *way* off-topic. If all you guys want to do is chat about how expensive the standard of living in country XXX create a new thread; this one's dead until some higher-up feels that there is a reason this thread should continue to exist.

Nick Evan commented: agree +23
majestic0110 commented: agree too +4
nav33n commented: How can you delete all the posts with racist remarks/replies but keep this post ? :) -2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I tried Collections.sort but i get this error:

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: assignment2009.studentClass cannot be cast to java.lang.Comparable

The arraylist i want to sort (studTranArray) contains a string and an integer.
While the example only shows a string being sorted...
is there a way to select the variable type you want for sorting and the String will follow?

The runtime exception is thrown because the `sort' methods expects the ArrayList elements to implement the Comparable interface i.e. the class should have a method which logically compares students. If you can't change your class definition [for e.g. if your value objects or classes are automatically generated], you can use a variation of the `sort' method which accepts a custom Comparator.

// NULL checks and some other minor details omitted for brevity
class Student implements Comparable<Student> {
   
   private String name;
   
   private int id;
   
   public Student(String name, int id) {
      this.id = id;
      this.name = name;      
   }

   public String getName() {
      return this.name;
   }
   
   public int compareTo(Student student) {
      return this.id - student.id;
   }
   
   @Override
   public String toString() {
      return "{name:" + name + ",id:" + id + "}";
   }
   
}

public class ProxyTest {
   
   public static void main(final String[] args) {
      List<Student> list = new ArrayList<Student>();
      Student student = new Student("tom", 12);
      list.add(student);
      student = new Student("dick", 34);
      list.add(student);
      student = new Student("harry", 0);
      list.add(student);
      student = new Student("a sexy girl", -12);
      list.add(student);
      
      // Use the comparable nature of Student class when sorting i.e. sort by id
      Collections.sort(list); …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

>What kind of problems?

Having an extra forum which would require all the house keeping a forum requires; monitoring threads, handling spam, moving off-topic threads/posts etc. We previously did create forums only to find them filled with spam and little or no activity.

BTW, is there any other reason you would want a separate forum other than the normal 'keeping threads organized' thing?

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

>Would it make sense to add a new forum to separate it?

No, seriously. Been there, done that; it causes more problems than solving any.

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

> Garbage collection happens only when there are exactly zero
> remaining references
Not exactly; circular references are also garbage collected. More specifically, objects are eligible for garbage collection if there exists no reference from a live thread to that object.

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

You need the mail.jar in your classpath; you need to download the JavaMail jars if you already don't have them.

You would also be needing the Java Activation Framework libraries [activation.jar] if you are not using Java 6.

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

Also, no need to do calendar.setTime(time) ; the new instance of the calendar has the current time.

BTW, if you find yourself fiddling around a lot with time related methods in your application, take a look at JodaTime.

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

Yes, Java 7 indeed seems to bring a lot of interesting things to the table. More confusion FTW!

> What I meant by "real" file system was simply that [...]

My explanation was actually aimed at the OP since I thought he was getting confused between the `File' class and the file-system file. :-)

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

> but it seems to work with a "real" file system on a "client side".

I'm not really sure what you mean by a `real' file system; the File class provides an `abstract filesystem independent view' of the path names i.e. your File object does *not* map to a real file on your file system. It's more of an abstraction provided to deal with `file' resources represented using path names.

BTW, I'm personally in favor of having a separate application specific class to represent a File or Directory structure. At first it might end up being just a thin wrapper for the File class but as and when features are added, it would serve as a good abstraction for containing all `File' or `Directory' specific state and behavior of your application.

stephen84s commented: For every post you write I find it difficult not to give a good rep +9
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Let's suppose that your program creates regex patterns based on the input provided by the user. Assuming the user enters `*' as the pattern and `hello' as the input string, the regular expression string would look like:

patrnStr = ".*" + ptrn + ".*";
patrnStr = ".**.*";

...which isn't a valid regular expression since it has a dangling meta-character, which is the *.

BTW, you can drop the ".*" present at the beginning and the end of your pattern string; they aren't required for detecting a match.

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

> Is the best way to do this using a Trie?
Judging by its description, it does seem to be a good way of doing things, better than regular expressions at least when used over a large data set.

A simple program to get the ball rolling:

package net.sos.playground;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class RegexTest {

   public static void main(final String[] args) {
      new RegexTest().run();
   }
   
   public void run() {
      Scanner in = new Scanner(System.in);
      String input = null, pattern = null;
      while(true) {
         System.out.print("Enter the pattern: ");
         if(in.hasNext()) {
            pattern = in.next();
         }
         System.out.print("Enter the input: ");
         if(in.hasNext()) {
            input = in.next();
         }
         if(testExistence(input, pattern)) {
            System.out.println("Match found\n");
         } else {
            System.out.println("No Match found\n");
         }
      }
   }

   private boolean testExistence(String input, String pattern) {
      pattern = Pattern.quote(pattern);
      Pattern p = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE);
      Matcher matcher = p.matcher(input);
      return matcher.find();
   }

}

Pay special attention to the testExistence method. The method Pattern.quote is required to escape all the regex special characters and treat them as literals. If, for example, the user enters a `*', which happens to be a special character signifying `zero or more occurrences', your Regular object creation will fail. The Pattern.CASE_INSENSITIVE flag is required since the default regular expression matching done by the String.match method is case sensitive.

Once the Pattern object for the given pattern and the Matcher object for the given user input is created, all that remains is to test for the presence of the given pattern in …

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

Marking this thread as solved since you already started a new thread which is a continuation of this one.

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

A simple way would be to remove all opening brackets "(" in your String and then split on ")," to get the desired result.

Another way would be to use the Pattern and Matcher object to do the same job.

Pattern p = Pattern.compile("\\(([^)]+)\\)");
Matcher m = p.matcher(s);
while(m.find()) {
    // Group 0 would be the entire string matched ('A', 'B')
    // and hence we are using group(1) which would give us
    // 'A', 'B' as desired
    System.out.println(m.group(1));
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Look into the batch execution capabilities of JDBC.

javaAddict commented: Thanks, I didn't know that +7
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> want to learn JNI , please suggest me some basic guide.

If you are doing it for fun, refer to the links posted above. But if you actually plan on writing a *real* application which requires interfacing with native code with the least possible fuss, try out some of the high level JNI wrappers and their likes out there.

JNA and Swig are few of them.

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

Does the server migration problem still exist since I can't seem to access Daniweb from my home most of the times? The request just times out. All other sites just work fine.

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

Posting complete solutions never has and never will help. How about giving the OP a chance to try out a few things before handing out a solution?

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

Let me again point you to my first post in this thread which clearly mentioned:

BTW, the `java' command expects a "package qualified" class name and not just a class name. So if you are using a package, make sure you use the fully qualified class name when invoking `java'. If not, then executing the `java' command from the same directory in which the class file lies shouldn't be a problem as such.

Does that ring a bell? Think what could have gone wrong, give it a second try and reproduce the entire session again in case you still face problems.

BTW, it's advisable to have the project placed in your personal folder; something like D:\personal\projects to avoid dealing with excessively long paths which IMO is messy.

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

Post the code of the class "as it is" without *any* modification, including the package declaration. Also paste the *exact* error message along with a screenshot of the entire session.

This shouldn't be happening if you are well aware of the points I mentioned in my previous post.

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

> So you would have to execute the command in this way :
> javac HelloWorldApp the class loader would look for a file with that
> name and a .class extension

A typo maybe? It should be java HelloWorldApp

> Exception in thread "main" java.lang.noclassdef

This question has been asked a lot of times on almost all java related message boards. Have you tired a web search with the given error message? Have you tried the solutions suggested in the existing threads?

BTW, the `java' command expects a "package qualified" class name and not just a class name. So if you are using a package, make sure you use the fully qualified class name when invoking `java'. If not, then executing the `java' command from the same directory in which the class file lies shouldn't be a problem as such.

Also, is the NoClassDefFoundError error thrown for the main class or some other class which the main class is using? In this case, you might have unresolved runtime dependencies which you will have to resolve by setting the appropriate classpath entries.

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

> Or is this affection that I'm hungary?

Don't turn this into a country thingy; reputation is a subjective concept so it can't be helped if someone thinks that your post was eligible for a bad one. But if you feel that someone is abusing the reputation system by repeatedly giving out bad reps for no real reason, feel free to report this to a mod/admin.

BTW, bumping threads is bad enough since it sends back the recent threads which are in need of help. Also, wasn't the reply you posted from some man page or online resource? Plus if you would read carefully, the OP was not having a problem with the command itself but more of a network issue.

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

The talk of vajinas[sic], strip clubs, mod infractions and tetris in a thread meant to *bring* Rashakil back does a bit of injustice to the "keep it on topic" and "daytime television" rules.

Locked to preserve the sanity of the remaining Daniweb members. KTHXBI.

Salem commented: <burns>Excellent</burns> +31
John A commented: Wut? There's sanity left? +21
Sulley's Boo commented: مشكور و ما تقصر +6
BestJewSinceJC commented: Rashakil for the loss. S.o.S for the win. +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Can we see how many guy(s) look at our profile?

AFAIK, you can't. This feature is much more common with social networking sites than programming forums. Join one in case you are more interested in stalking those who stalk you. ;-)

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

Like I had previously mentioned, there is no need to loop over the result of the split method call. The split method returns an array whose elements are the host, ip addr and the ping.

Just remove the "for (String str : values) {" part and you should be good to go. For future references, please make sure you post a compilable piece of code which can be easily copy-pasted and run without making the poster jump through hoops to get it working.

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

Post your latest copy of compilable code which exhibits the behavior you mention [i.e. duplicate printing] along with the relevant CSV file.

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

> it duplicates the information its printing out by 3

Because you print out the information in a loop. The solution here is pretty simple; split the string read from the file/stdin using the given delimiter. If the length of the resulting array is not equal to 3, it means that the input wasn't in the format required. If the array length is 3, print out the details using:

String[] arr = str.split(",");
// assert length of the array is exactly 3
System.out.println(arr[0] + ", " + arr[1] + " and " + arr[2]);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

OK, thanks for finally getting the point. BTW, this thread is going down on grounds that it might again turn into a "hail narue" chant by Serkan and for going a bit too off-topic.

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

I think the OP is talking about the "copy constructor" like functionality which exists in C++ and can be implemented in Java by:
- implementing the Cloneable interface
- overriding the clone() method of the Object class

@grisha83

Read the documentation of the clone() method of the Object class and this for more details.

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

> Why should I do this(in bold)? :

Because we require the hex equivalent a generated byte and not the integer this byte gets up-casted to. When converting to hex string, we would want our toHexString() method work on an integer which represents the sequence of bytes generated by md5 and not the integer which the byte value gets automatically upcasted to.

For e.g. if the first byte generated by the md5 algorithm in your case (with input "abhi") has a binary pattern "11010111", we would want the hex equivalent of an integer having the same bit pattern i.e. "00000000000000000000000011010111". But the integer which results from the auto-conversion of "11010111" is of the form "11111111111111111111111111010111". Hence you need to AND the byte in question with 0XFF [00000000000000000000000011111111] to make sure all the higher order bits other than the byte in question are reset to 0.

> Isnt it the incorrect output?

Read the python documentation, hexdigest() is the method you should be looking for.

abhi_elementx commented: It's very informative +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You don't need to change the signature. You can obtain the `Class' instance of the primitives using either `int.class' or 'Integer.TYPE'.

import java.lang.reflect.Method;

public class Reflection {
	
	public static void main(final String[] args) throws Exception {		
		Method m = new Test().getClass().getMethod("doForInt", int.class);
		System.out.println(m.invoke(new Test(), 1));
	}

}

class Test {
	
	public int doForInt(int i) {
		return i;
	}
	
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Also, consider moving the `parse' method to a separate implementation class coded to an interface to allow for greater flexibility.

Is that file format predefined or something which you have designed yourself? If the latter, then there are better ways of representing the same information. Just move all the point coordinates on a single line removing the comma in between them. Read a single line from the file and split it with `space character' as a delimiter. If the size of the array after split is not divisible by 2 [the number of coordinates which constitute a point in 2D], consider it to be an invalid set and skip the computation. If the size is divisible by 2, then the size of the point array should be the size of the split array divided by two.

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

When do you think the compile time error 'symbol not found comes up'? What does your text book say about such errors? The example you posted seems a pretty bold one for someone who has just started out with Java.

Anyways, the error message means that the compiler doesn't know about the token 'DateFormat'; `import' the class in question and you should be good to go.

redmaverick commented: Thanks for helping me out! +1
Salem commented: Kudos for bothering to trawl through zero-indent code. +29
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> it also supports the idea of how c++ sucks.

Just because Linus thinks C++ sucks doesn't mean we feel the same way; he isn't god you know. Also, AFAICT, he is trying to say that:
- C++ is a difficult language, at least when compared with C
- There are more ways to abuse and more substandard programmers in C++ than in C

As an analogy, please don't hate your OS just because it allows you to format a partition with a single click; with great powers come great responsibility...

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

If the entire code base uses generics, there is no way that would happen; after all, generics were introduced for this very reason. Are you sure that the code base doesn't ditch generics and falls back to raw collections at some point? Have you used a debugger to trace the program flow so as to view the methods which add data to the vector?

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

> what is wrong with being "Narue obsessed"?

Nothing is wrong in being obsessed with 'XXX'; just make sure you don't end up causing inconvenience and chaos with your *obsession*[which you just did by posting this thread in C++ forum, making it an off-topic thread].

stephen84s commented: Yep this obsession had gone over the line last time also +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Please Explain. Where i have to change the code?

Try changing your markup; your HTML page doesn't understand your *servlet project* and hence you need to specify the extra "/test" before your servlet name.

> So where i have to include DB Connection code?

In your DAO classes.

> i have reffered many books but i didnt get the proper
> knowledge... Help me please.....

Refer the sticky thread at the top of this forum along with the JEE 5 documentation for some concrete examples.

stephen84s commented: Ah... So is it finally the return of the king ??? :P +7
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

NaN. Read the section on "How NaN is created", step through your code a single method at a time and it should be pretty easy. Use a debugger; a slick one which comes with Eclipse or a primitive command line debugger like "jdb" should do the job.

Salem commented: NaN - more than just an elderly female relative :) +29
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

AFAICT, the <sql:param> tag needs to be nested inside the <sql:query> tag.

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

> My insertion sort algorithm is failing to properly sort the points
> based on angle roughly 30% of the time.

That isn't an Insertion sort which you are trying to implement; also whichever algorithm that is, it's broken. Try it for input [5, 8, 1, 2].

Read this.

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

Like it has already been mentioned, post your code which can be compiled and tested to reproduce the exact problem.

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

It's not officially against the rule since any valuable addition to a thread discussion is more than welcome. Useless bumps to old threads are simply forked off as new threads. Just report any such occurrence and the moderator team would act accordingly.