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

or if there is one then where to find it ?

Adding to Davey's answer, the technical reason is that if you use a "textarea", the browser pretty much automatically fills in the spell checker's role for you. Unfortunately if you'll notice, the Daniweb answer box is implemented as a div instead of a textarea resulting in no support from the browser. I'm really hoping Daniweb revamps the current answer area to use a textarea instead of a div. :)

iamthwee commented: +1 +0
WaltP commented: Looked like a plus thwee... ;) +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A forum software is almost always a server-side web application which runs on a servlet container (Tomcat, Jetty) and is powered by a view technology like raw JSP's or JSF. As far as suggestions go, it really depends since the web-development landscape is pretty much saturated with a lot of technologies. One way would be to go the raw JSP route which is a bit painful/verbose and is as primitive as it gets (Servlets are not really a view technology).

If you are doing it for fun/learning, then going the JSP way would teach you a lot of things. If you are doing it with the intent of making it big with your software, using a framework is pretty much a requirement to shorten the time-to-market. There are three big/famous ones which come to mind:

Like any other technology out there, you'll have to play with a bunch of frameworks to understand which one is a perfect fit for you. Unfortunately, there is no easy way out and picking up a forum software as your first software is a tough nut to crack IMHO especially if you are new to Java. Good luck.

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

so like admins are working on daniweb, is this a full time job for them ? I mean is it their part time job or complete full time work ?

It depends. I'm one of the admins who isn't strictly employed by Daniweb/Dani. I contribute to Daniweb in my free time just like the other moderators here.

Davey and Deceptikon are employed by Dani for being a staff writer and Daniweb developer respectively though I can't comment on the "full time" part.

secondly, like sanjay is indian, so is he working from india ?

Yes, I "contribute" from India.

So they all work sitting in on place ? strange !

"Come together" as in bring together as a group of tight knit people who contribute to/work towards the betterment of Daniweb. We don't actually sit or "work" from a single place.

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

That really shouldn't be happening. For the time being, go to the profile page and check the 'disable ads' checkbox. See if that makes a difference. Hopefully Dani will pick up this bug report when she is online.

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

Nitin, I don't think it's reasonable to coax someone to reply to threads they aren't interested in. Further coaxing/requesting would just make them lose interest in replying to any of your threads. Let's just respect each other's preferences, shall we?

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

Also mods rely on the "flag bad post" reports by regulars to keep the forum clean so as long as any "regular" flags off-topic posts, it would be a big help and should make the life of moderators easier.

Also, to kickstart the thread, it will be a good idea to "mimic" the one in the Python forum and let the regulars decide the direction which the thread should take.

rotten69 commented: I agree with you on that! +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I have replied to James in the mod section and I'll reply here again. I'm favour of a new sticky thread as long as it stays on-topic and doesn't become a dumping ground for "plz halp me" posts. Someone will also need to ensure that "reponses" to the challenges/projects are not posted in the same thread so as to clutter it. It's a difficult task (e.g. take a look at the number of deleted posts in the current Java forum sticky) but if the Java forum members can pull it off, it would be a nice addition to the forum. That being said, I approve of the idea and would be more than happy if James lead the initiative.

rotten69 commented: Thank you for liking the idea. Yeah, it needs some serious action and someone keeps an eye on what is posted. +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem is that once the member is taken to an "old" thread via the "related article" link, the reply box doesn't show "how" old the original question is. It is kind of given that new members will think that it is OK to respond to the thread. For e.g. one of the articles I navigated to, which was solved 8 years back just shows me "this thread has been solved".

I don't think that is enough to stop newbies from resurrecting old stuff. I think a bit more detail like "This thread is XX years old; if you want to ask a new question pertaining to this topic, please create a new thread" with the "create a new thread" part linked to "create a new article" URL.

Ancient Dragon commented: good idea :) +0
diafol commented: Second that as a good idea +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Important details are missing from your post. Which OS (Win 7 64 or 32 bit)? Which Java version (32 or 64 bit JVM; try doing java -version at the command line)?

If you are using a 32 bit JVM, you need to install 32 bit SWT. Likewise, for convinience, make sure everything is 64 bit (i.e. Java and SWT) in case your OS is 64 bit.

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

Your situation sounds a bit similar to what I've been through in the past so I'll try to put my 2 cents here. The wall of text presented below assumes that you want to land up in a good company and become a better programmer, not just the former.

Is it better to learn a maximum langage syntax, so im not limited to php, c and java or i better go deeper in 1 langage so i really get good at it and apply only on that langage, so far i really like Java?

Programming is not just about knowing the syntax; it's more about implementing your "logical problem solving" constructs. Let's say you want to write a method which returns a toString implementation of an array. No matter what the language, the core concept of this little exercise remains the same. Sure, you have to know Java to write it in Java, but if your only strength is the "syntax", then you would find yourself struggling with code even though you know Java. Try not to take on more than 3 langauges when starting out because it might turn out real confusing with your language expertise kind of "spread out".

nearly the same question as 1, but about the field of interest. should i take 1 field of expertise and develop my knowledge on that, exemple: its been 9 months, that i work around communication and the asterisk platform, going deeper in communication is good or …

Swordstech commented: thanks for the CS course links +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The actual differences can be found here. And yes, Glassfish as an application container provides many more features when compared to a servlet container like Tomcat.

Also, depending on the complexity of your application to be ported, you should look into other lightweight alternatives like the Spring stack in case you are looking for migrating an enterprise or simple web app.

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

Not directly related to the content but I'll "get if off my chest" anyways. We need an easy way to access past newsletters and a pretty visible link at the top so that new members can click and read some old stuff, interviews etc. I think that this feature has been missing for quite some time.

And to be a bit more on-topic, I think a brief extract/gist of the latest and greatest discussions which happen in the community feedback forum, area 51 needs to go in that newsletter to make it a bit more spicy (please do ignore is this is already the case).

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

And i assume the suggestions have the same problem?

No, really. Right now your code is inefficient and complicated because:

  • You are reading the entire file in memory; this is obviously going to cause problems in case multiple clients request several big files concurrently which would result in an OutOfMemoryError
  • If your only aim is transfer a file, there are simpler ways of knowing when a file ends; the trick is that read returns -1 when there is no more data to be read.
  • The actual code/algorithm is much simpler that what you have right now:

    • When client requests a file, open the file using FileInputStream on the server
    • Create an intermediate buffer as I have in my sample code snippet posted in my previous post
    • Keep reading data from the file input stream by passing in the buffer.
    • If there is more data to be read, read method call will always return the number of bytes read from the file. If end of file is reached, read returns -1 in which case you know you need not read any further.

Changing the code which you have should be as simple as just using the copy method on both the client and server piece of code. The only difference is where you get those streams from. In the case of client, the InputStream will be the input stream from the Socket which you created and the OutputStream will be the output stream for the new …

Krokcy commented: Informative, concise and understanding. +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Based on my experience, Python is an outstanding first language and it maintains its appeal even to veteran programmers. But if your goal is to develop any kind of serious GUI, be prepared to invest a lot of time in learning details which you should not have to be concerned about.

A conclusion I don't agree with. IMO you are not comparing languages but the tooling support. There isn't anything inherent in VB.NET or Python as a language which makes one superior over the other when it comes to developing UI's. It's just that the tooling support for VB.NET is excelllent (Visual Studio) which makes it a breeze to create UI's. If you want to experience something similar with Python, take a look at Nokia's Qt (with QtCreator) and the corresponding Python bindings (PyQt and Pyside). Sure, the experience might not be the same as Visual Studio but is pretty decent when compared to creating UI's by hand.

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

When i write my code, in the if statement the compiler gives me an error. It says that initialize enum

Whenever you declare a method scoped variable, you need to assign a value to it at least once before using it. In your code, the variable myStatus is not initialized before use. Either give it a default initial value or add an else to your existing if construct. Something like:

if (number != answer){ 
    myStatus = Status.CONTINUE;
} else {
    myStatus = Status.WIN;
}

You might also want to move the part where you accept user input inside the loop. Another good way of avoiding repetition would be to use a do...while loop.

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

I don't know exactly how you propose to use the given interfaces or how they fit in the big picture of your application so take this as a generic observation/food for thought about the way current code stands. :)

IMHO you are facing problems here with structuring code since the abstraction is leaking out a little bit. You create BufferValue class to abstract out how buffers work for floats, colors etc. but expose the internal type T when doing operations. Your operations return T which make it difficult to chain opeartions or work at an involved level with the returned results since there is no bound specified for T. With the current design, you'll also face issues when interoperating with different BufferValue's since the return type is T which is different for FloatBufferValue and AwtColorBufferValue.

Now back to your question: the lerp method sounds like a good candidate for the helper class which normally accompanies a widely used interface. For e.g. java.util.Collections used for manipulating and housing utility methods of the java.util.Collection classes. For e.g. one implementation can look like:

class BuffersValues {
    public static <T> BufferValue<T> lerp(double a, BufferValue<T> first, BufferValue<T> second) {
        // something here
    }
}

Now we have a problem here; we need a way for double values to interact with the containers of the BufferValue class, namely Float and Color. There are a few solutions which spring to mind:

  • Wrap the double value in a DoubleBufferValue and use the mul/add/etc. methods
  • Change double …
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I was able to upvote it; you just have to do it real quick. ;)

But jokes aside, I wasn't able to upvote once the rep comment box comes up after on-hover.

pritaeas commented: I have a slow mouse ;) +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Both are free as long you run it with public repos, as soon you want private repo you have to pay

Bitbucket allows you to have unlimited private and public repositories for upto 5 colloborating users. I always recommend Bitbucket to folks since you can pretty much host all your code privately and even run a small business (with < 5 programmers) for free!

peter_budo commented: Didn't know that +15
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Its just a simple question , but i m totally confused that why php and asp hosting are cheaper then jsp

One reason might be the widespread use and acceptance of PHP and ASP by hobby programmers/beginner web developers. Java based applications have always been associated with an "enterprisy" setup hence the steep prices (enterprises can shell out more as compared to hobby programmers). Another interesting read in the comments here.

Also what jsp provide which are not provided by php and asp?

This eventually boils down to a platform/language based comparison. Can you make do with the features offered by the PHP langauge? Is there something specific you had in mind when you decided to include Java?

A pragmatic answer here depends a lot on what exactly do you want to do. Are you planning on creating a web application or a web site? Is budget a big constraint here?

If you are short on budget, are planning on creating a hobby website and have a familiarity with PHP, going the PHP route would be the simplest and cost-effective solution. If you are creating a critiical web application for a customer, the criteria would be to choose a combination which best suits your expertise since you would want to create a robust solution. In this case, go with the language you are most comfortable and well-versed in.

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

All admins, moderators, team colleages are employees or some of them just contribute their time to site

All moderators are voluntary contributors (not employees) to this forum who help out Daniweb with answering questions and forum maintenance in their free time. Except for me, all other co-admins are Daniweb employees (namely Davey & James).

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

Markdown is better not because it has great preview etc. but because you don't require special keywords to do the formatting which is so much easier for the end user. Markdown is clearly inspired by the newsgroup way of doing stuff. For e.g. I don't need to use the pseudo XML syntax with square brackets to tell the parser that I want so and so text segment quoted. I can just use > and be done with it. Similarly with bold and italics. What's more, Markdown text doesn't look like a load of markup text written to do some simple formatting. It just works with the minimum possilbe noise.

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

Hi folks,

Please join me welcoming our two new moderators: ardav and pyTony.

@pyTony & @ardav
Congratulations on your new role at Daniweb. Celebrations ahoy! :)

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

Hi folks,

Spring 2012 anime is just around the corner! The chart stating the names of the anime to be aired along with their tentative dates can be found at: http://atxpieces.wordpress.com/2012/03/01/spring-v3/

I would definitely be watching the below:

  1. Zetman
  2. Accel World
  3. Eureka 7 : Astral Ocean
  4. Fate Zero II (Hell yeah!)
  5. Jormungand
  6. Kimi To Boku 2 (An exceptional slice of life anime)

If you are planning to watch this season, what's on your list? :)

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

This is not an issue but a concious site-wide decision. IIRC, this was put in place to ensure we don't end up getting members who post for the sole purpose of "exposing" their sig links to "teh internet". As a user, you have no control over this behaviour, so no, it can't be resolved.

Similar thread in the past.

happygeek commented: absolutely +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Fixed title; you can always try to get the title edited by "flagging" it as bad post.

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

What kind of file is it? What kind of "text" does it contain? If it contains ASCII encoded text, you'll always get the char count of a string same as the number of code-points. Read this, try to understand it and get back in case of more queries.

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

So? It still doesn't change the fact that it will fail for certain inputs as mentioned above and the worst thing is that regular tests which don't exercise the limits won't be able to uncover this problem.

Please don't provide sub-standard advice to beginners who wouldn't know the difference between "working" and "correct" code. It's a pity that my post, which tried to push adil in the right direction was downvoted. If someone wants to challenge my post above, I would be more than happy to provide reasons/discuss.

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

Convert it to long first using Long.parseLong() and then convert the long to BigInteger using BigInteger.valueOf(long val)

This won't work if the string representation is outside the "long" data type range, which is one of the main motivation for using BigInteger...

thanks dear it worked, but isn't there any direct way for such a conversion??

There is no direct way to do these conversions given that like C++, Java doesn't support operator overloading.

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

In what way is the BigInteger constructor which accepts a string not working out for you?

Philippe.Lahaie commented: the constructor that receives a char array was definitly the right answer all along ;) +6
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try wrapping the `value` elements in a parent element called `values` and have a look at this thread.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
Ezzaral commented: Excellent song! +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'd personally recommend a file/directory copy utility. This way, he'll get more acquainted with how the CLI clients work and get a taste of implementing a fun utility from scratch. The good thing is that this project can be beefed up if required by adding more options like the way a real copy command works. Bonus points for progress bar etc.

zeroliken commented: you make it sound like it's just a walk in the park ;) +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Two ways of doing this:

1) NULL checks every time you add an element. If the "key" is not associated with any underlying set, create a new HashSet, and place it against the key.

Set<State> states = mapping.get(transitionStringToAdd);
if (states == null) {
  states = new HashSet<State>();
  mapping.put(transitionStringToAdd, states);
}
states.add(transitionStateToAdd);

2) If you can afford adding a library, Google Guava provides a class just for this use case: HashMultiMap. It relieves you of the NULL checks but of course something similar is going under the hood. The new code after using this class will look exactly the same as your code snippet.

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

"make" is a standard "build automation" utility which is pretty much available on *nix like platforms. For more info, read this. The core concept is that instead of firing the commands required to "build" a project again and again, you stuff them in a "makefile" and distribute them to the users to allow them to build stuff without knowing the internal dependencies/structure of the project.

Apache Ant is similar to "make" in the sense that it is a build automation tool *but* differs in the sense that it uses "XML" as the automation language instead of a home grown one (like make does). Also you won't be completely able to understand the statement "without make's wrinkles" unless you have used "make". For the time being, just assume that make has it's pretty share of problems. If you need more info, try this.

BTW, Ant is pretty much a legacy solution when it comes to "build automation" in Java land these days. Maven is the de-facto tool for both build and dependency management solution when it comes to Java projects. Of course, it still has its share of problems (using XML being one of them). AFAIK, Gradle works towards the goal of using Groovy, a full fledged DSLish language for build automation and at the same time using Ivy under the hood for dependency management but I'm not sure how it works when it comes to integrating with an IDE (Eclipse/Netbeans).

TL;DR: …

peter_budo commented: Couldn't agree more. +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

It still displays the old one!? Whyy??

Apart from answering the questions posed above, make sure that you do a clean build and then run the application. It's quite possible that the old image still resides in the build directory of Netbeans. Also, check where exactly is this application run from (search for the dir Netbeans uses) and verify it has the same image in consideration.

peter_budo commented: +1 for clean build +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Sorry, but I still didn't get it.

Fair enough. To understand the need for a solution, you need to first have a good grasp on the problem you are trying to solve. So my question to you is: what would be your solution if you are asked to come up with a way to ensure that clients are forced to implement a subset of methods found in an interface? E.g.

interface Template {
  Environment getEnvironment();
  byte[] renderToImage();
  String renderToString();
}

Let's say renderToImage() is a convenience method which uses renderToString() to output the image. If I have to create a class which only needs to implement renderToString(), what would be your solution?

Check here the java docs help me understand even the most complex of definitions:http://docs.oracle.com/javase/tutori.../abstract.html another good def:http://www.roseindia.net/help/java/a...-keyword.shtml

Please don't quote Roseindia, they are content thieves.

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

I'll try to explain this with an example. Let's talk about a simple templating system which is based on a single Template interface. Every different template implementation has a different way of interpolating variables, convention used for representing data etc. But all templates also share a common piece of logic: they all interact with the "environment" i.e. state, they all are capable of being serialized to common formats like PDF, PS etc.

My concern as a template framework provider would be to prevent code/effort duplication for template implementers i.e. classes which provide different template support. To that end, I create a convinience base class which would be extended by all template implementers and which has the common logic required for all templates. But I have two problems:

  1. I can't enforce template writers to override/implement a method. For e.g. I would want each template writer to override the render() method which takes a template, environment and produces a rendered output as String.
  2. I can't prevent instantiation of the BaseTemplate class.

These two problems can't be easily handed by a normal class. Enter abstract classes. You want to enforce template implementers to override a given method? No problem, just make it abstract. You want to enforce non-instantiation? No problem, make the entire class abstract.

Of course, I'll also mention that you can't have abstract methods without making the entire class abstract because as per common sense, you'll really not want to "instantiate" something which isn't complete (yes, …

stultuske commented: never been good at explaining myself :) +12
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

it just increases the size of your code because then you are importing everything from the IO package

This statement is a bit misleading. It doesn't increase the size of your code. If you'll disassemble the class file, you'll notice that classes are anyways referenced using their fully qualified names (i.e. java.io.BufferedReader instead of simply BufferedReader). The imports are anyways used to manage/locate compile time dependencies.

That being said, the reason wildcard imports are not recommended (unless throwing together snippets) is that it becomes difficult to trace which class was imported from what package. This of course if mitigated by using an IDE but is a good thing to know just in case.

peter_budo commented: There you go again, "smart pants" answer. Nice summary :) +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Few points:

  1. close() calls should always go in the "finally" blocks
  2. Never use System.exit() to duck out in case of failure. If your code is used in a large/big setting, exitting the JVM in case something fails isn't pleasant. Boolean returns are your friend.
  3. Always check the return status of "delete()" call because file deletion failures are pretty common.
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> i got this code form the internet where it can delete a file.but when i tried to use it n my own java program it does not work anymore.it always returns 'Could not delete file'.

First thing, never have empty catch blocks in your code, ever, no matter what. Second, your code doesn't handle special conditions where failure to close a stream will result in other streams remaining unclosed thereby leaking file handles. Third, if the file "person.txt" is opened in Excel or some other program, it will allow you to read data from it but block deletion since the file is already open by some other application.

For first point, make sure you always log exceptions or at the very least print stack trace. For the second point, if you are using Java 7, you can write:

try (BufferedReader in = new BufferedReader(new FileReader(f)); PrintWriter out = new PrintWriter(tmp)) {
    String s;
    while ((s = in.readLine()) != null) {
        out.print(s);
        System.out.println(s);
    }
}

And your streams will automatically be closed after the "try" block completes.

For third, make sure *no* other program is currently reading or has the given file open.

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

A label in Java can be used for regular code blocks and IF statements along with their regular usage with looping constructs. So you can have:

something:
if (i == 1) {
  method();
  int j = method2();
  if (j == i) {
    break something;
  }
}

Similarly with blocks:

something: {
  method();
  int j = method2();
  if (j == i) {
    break something;
  }
}

Do keep in mind that "continue" can only be used from within looping constructs considering that's the only place it makes sense.

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

Look into the "connect()" method of the `Socket` class. Basically, you create a blank socket and ask it to connect to a given destination with a specific timeout. This connect() call blocks until a connection was made or timeout was encountered.

// untested
final Socket sock = new Socket();
final int timeOut = (int)TimeUnit.SECONDS.toMillis(5); // 5 sec wait period
sock.connect(new InetSocketAddress("host", 8080), timeOut);
Majestics commented: ............................................................................................. +8
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

From your first post, drop the extends Thread. If you want to submit a task to the pool, just make your task implement Runnable or Callable instead of extending Thread.

Also, a clarification - you are not cancelling "threads" but cancelling the "future". This is a big difference because if you use a fixed thread pool, a single thread will be used to execute multiple tasks and in turn return multiple futures.

Now, the simplest solution to actually stop a computation is to "listen" to interrupts.

public Task call() {
  while (true) {
    if (!Thread.currentThread().isInterrupted()) {
      // do something
      System.out.println("Hello world");
    }
  }
  return this;
}

The reason it works if you put sleep() is because, sleep is a blocking call which throws an interrupted exception when the sleeping thread is interrupted from outside. Though sleep works, it's not a good solution because it most probably toggles the thread state as opposed to just checking the interrupt flag.

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

I don't think this solves anything if your purpose here is to "cancel" the underlying computation. Create a task which continuously (while true) prints "Hello world" to the console (STDOUT) every second and set the timeout for that task to be 5 seconds. You'll notice that even after the task has been cancelled, you still get "Hello world" printed to the console. Why? Because, cancel() on Future *attempts* to cancel the underlying computation. Sure, you have expressed your desire that you don't need the future, but this doesn't mean that the "underlying" processing has stopped.

To summarise, unless your "task" is thread interrupt aware, calling cancel(true) has no effect on the computation. If you are iterating over a *large* number of element, with some processing done for each element, you are in luck since you have time window for polling the interrupt status of the thread. If you are invoking a blocking call like doing traditional I/O, you are out of luck and the only way would be to forcefully close the I/O stream/handle.

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

AFAICT, the web client works across all browsers (assuming you have no "blocking" plugins installed). Give this link a try and let us know how it goes.

PrimePackster commented: Thanks +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

My bad, I meant javac. What does javac -version print? Also, does it work when you use javac -source 1.6 -target 1.6 compute/Compute.java compute/Task.java ?

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

I don't think there is a clean way of doing this in RMI given RMI doesn't offer an appropriate level of "socket" abstraction for this sort of stuff. Your best bet would be to pass a "callback handler" when "registering" or "joining" the chat. When the server wants to kick a client, it will just use the callback handler for that client (maybe stored in a Map at the server, name -> callback handler pair) to invoke the "kick" method. This kick() method will then be called in the "client JVM". In that method, you can "NULL" out the reference for the chat server.

Your client now no longer has the reference to the server and will have to make another call to "join" the chat. Just make sure you also call System.gc() and System.runFinalization() to ensure that the distributed garbage collector (DGC) kicks in and performs the necessary cleanup.

Some sample code:

public interface CommandHandler extends Remote {

    void kick() throws RemoteException;

}

public class CommandHandlerImpl extends UnicastremoteObject implements CommandHandler {

    private final Client client;

    public CommandHandlerImpl(Client client) {
        this.client = client;
    }

    public void kick() throws RemoteException {
        this.client.chatService = null;
        System.gc();
        System.runFinalization();
        System.out.println("You were kicked from the server, please reconnect!");
        
        // update UI by clearing out all text boxes, list boxes etc. so that the user gets
        // the impression that he was "actually" kicked out.
    }

}

// Your main application class which has the chat server reference and …
Ezzaral commented: Nice solution. +16
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I'm not sure what's the confusion here:

// add same elements twice; should be added only once
set.add(i1); 
set.add(i1);

// add new element; size is now 2
set.add(i2);

// remove added element, size is now 1
set.remove(i2);

// remove a non-existent element, shouldn't affect set
// size is still 1

// this part performs auto-boxing i.e. i1 now points to a new Integer object 
// having value 47
i1 = 47; 
set.remove(i1);
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

my part of code give me message to recompile with -Xlint:unchecked
How to fix this code so the message gone

JComboBox was made a generic type in Java 7 so creating a new JComboBox without supplying the type parameters would result in the usual "unsafe" warning. The solution here would be to specify the type parameter when creating the combo box, something like:

import javax.swing.*;
public class Test {

    public static void main(final String[] args) {
        final String[] strs = { "a", "b", "c" };
        final JComboBox<String> cbox = new JComboBox<>(strs);
    }

}
mKorbel commented: Object not String +10
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Ok thanks and happy new year.
when i said "when i'll master them" i meant when i'll master the core language.
I wanna develop programs that can connect to the internet, ping, scan network, etc.
So which language is most used for these kind of stuff ??
thanks again

The general rule of the thumb is to have knowledge of:

  1. A language close to the metal and generates fast and native code. C or C++ are good contenders for this category.
  2. A language which can be used to execute quick n dirty tasks and prototyping. Python, Ruby or Perl fit nicely in this category
  3. A language which can be easily used to put up a web application without much fuss. Again, Python and Ruby are good contenders for this category.
  4. A language which has awesome commercial support, public following and guarantees job security. Java and C# along with their frameworks/libraries are good contenders for this category.
  5. Knowledge of the "shell" for the OS you work on. Shell scripting on *nix and Powershell for windows (or bat scripts if you are brave enough) fall in this category.

After that, feel free to learn any more languages which you learn to broaden the scope of your skills and knowledge.