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

Think of the JVM as a universal VM. JVM byte code is to JVM what x86 assembly is to x86 family of processors (sort of) with the difference being that this byte-code is not aimed at any specific processor architecture but rather a VM which runs on a variety of architectures.

The platform specific stuff is taken care by the different "JVM implementations" which are tasked with taking in the "platform independent" byte-code and translating it to the corresponding platform specific machine code. Here, the JVM installed on your machine performs the job of the translator; translating a machine independent "code" to machine specific code.

arshi9464 commented: person has a lot of knowledge about the subject +2
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

That effectively means that if we want to access the protected members of a class outside the package through an object of its subtype (say ob), we can do it only within a class (say A) that is either the same class to which ob belongs or its supertype

Yes.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
tux4life commented: Awesome :) +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

How could I solve this problem?

By using a high resolution image? If you would try to zoom in on a 128 * 128 image, it would obviously look bad.

Two options AFAICT:
* Use a new image as the image source every time a zoom is done instead of scaling the same low resolution image
* Use vector graphics instead of raster graphics which provide infinite zoom capabilities

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

Looping over the array and comparing values would be the simplest solution. If it is an array of primitive values, use the comparison operator == . If it is an array of reference types, use the equals method (or compareTo if the reference type implements natural ordering).

Another simple way would be to make sure your array is sorted ( Arrays.sort ) and then use the Arrays.binarySearch method.

http://download.oracle.com/javase/6/docs/api/java/util/Arrays.html
http://www.java2s.com/Code/Java/Collections-Data-Structure/ArraySearchTest.htm

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

Thank you ~s.o.s~ for your response.I have seen your all posts its all nice .It shows your passion and commitment to the work .

You are of course welcome. :-)

Is any one know about the oracle certification in java exam patterns(format).

I've earned a couple of certifications when Oracle Certification was still Sun Certification.

AFAIK, it's only the name that has changed, the subject matter remains the same. For the entry level certifications (SCJA, SCJP, SCWCD), topping the exams is as simple as knowing the Head First book for that particular certification like the back of your hand. Plus of course a bit of practice.

You'd be surprised given the large number of folks who think that just reading the same content over and over again would be sufficient. If you are approaching a certification, make sure you *practice* each and every thing you learn i.e. learning by doing. Also, make your own set of notes which kind of contain the extract of each and every chapter which you are easily refer one day before the examination. Coupled with helping out other people on Java certification oriented forums (this or some other site) would greatly increase your knowledge about the subject matter.

Good luck. :-)

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

Does that mean that the first line of Code 2 is equivalent to

Yes

That would explain why ob[0] can be assigned a String too.

Just remember that it really doesn't matter whether you have a new Object[] { 23 } or new Integer[] { 23 } since as long as ob is of type Object[] , you can always do ob[0] = "HI" .

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

Yes it's purely textual data - just for an assignment ;) with the current code it takes around 8 minutes to encrypt a 600mb text file using a simple substitution cipher. What do you think, is it decent?

Nope; because for a simple substitution cipher like Caesar cipher, I can encrypt a 600 MB file in 40 seconds. :-)

Are you still reading the file character by character since that would explain your timings?

I think you are getting OutOfMemoryException when using readLine() because your sample 600MB file does not contain any newline and hence the Reader tries to read the entire file content in a single String. The most effective solution here would be to use FileReader/FileWriter and implement your own buffering (32KB buffer would be a good one).

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

What are the things(portions) which are covered in J2SE and J2EE ?

Too big to cover here; read:
* Java SE: http://www.oracle.com/technetwork/java/javase/tech/index.html
* Java EE: http://www.oracle.com/technetwork/java/javaee/tech/index.html

Did java has a further development after oracle brought sun.

The feature list of the Java 7 release (the next version of Java)

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

What I don't understand is that Code 1 will throw an exception when run while Code 2 won't. The two methods of array initialization behave differently at runtime. Why ?

The code you posted is not two different methods of array initialization but two completely different arrays. Try printing out the class of both those arrays to confirm the same. (i.e. ob.getClass() )

The other thing I was trying to ask (and messed it up) was that in code 1, since the compiler knows that an Integer type array has been assigned to ob, why not flag the assignment of a String to it (in line 2 of Code 1) as an error ? Why wait for runtime to throw an exception ?

Let me counter that question with another question from my side; why does this piece of code not compile?

public boolean doIt() {
       final int i = 0;
       if(i == 0) {
           return false;
       }
   }

Isn't it dead obvious that "i" will be 0 when the IF check is made? So why throw a compile time error?

There is a limit to how "smart" the compiler can be or how smart the compiler writers want it to be. If the compiler could, it would have checked that the user has left off a return statement and then try to see what value "i" has. But this would involve kind of "running" the code or simply put establishing a runtime context for the code …

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

> j2se vs j2ee vs j2me .

Simply put:
J2SE - Standard edition; standalone applications
J2EE (is actually called Java EE) - Enterprise edition of Java for managed applications; built on top of Java SE and adds enterprise capabilities (read specifications) like web applications, business components etc.
J2ME - Java for mobile platform; kind of stripped down version of Java SE with added mobile development related API's

I want to do sun certificate in java.Can any one have idea about the sun certificate.

What kind of *idea*? BTW, it's now Oracle and not Sun certification. Sun is dead.

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

That's strange. Do you have multiple JVM's installed on your local machine? Which Java version are you using to compile your project i.e. what's your JAVA_HOME and PATH set to?

Even if it were related to different JVM versions, I don't think the error would be NoClassDefFound. Are you sure you have the entire stack trace there? Can you empty the log folder on your local setup, restart the server and paste the *entire* stack trace here?

Also, space in directory path causes real strange issues so can you relocate your local Tomcat directory to something like "c:/tomcat-7" and then try again?

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

There is something definitely wrong with your setup because I'm able to run the same thing locally without any problems.

Is your Tomcat installation clean or have you made any modifications to it? Are there any other apps successfully running on the same Tomcat installation? What is the entire directory structure of the "tut" directory in the "webapps" folder? How do you start Tomcat?

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

using the "new" operator that hardcodes the fact that any object passed into the array must be Integer or a subtype of Integer. The other is : Object [] ob={10} which doesn't hardcode that fact. Here, we can assign even a String to ob[0].

No and yes. No for first because Object[] obj = { 10 } is just an alternate way of declaring an integer array since the compiler "infers" the type here. And yes for second, because irrespective of the "expression" on the RHS, the compiler "has" to allow the statement obj[0] = "HI" .

The example u gave used the second type to which the compiler is inherently lenient.

The compiler is not lenient here; read above.

But if we used the 1st type, the compiler knows for sure that ob has been passed an array of Integers. So, shouldn't it flag any attempt to add a String to it ? Whywait for runtime ?

How does the compiler know for sure? The method invoked and the type of array passed depends on the "positionOfTheStars()" output which is decided at runtime. I'm not sure why you think the compiler can catch this at compile time.

if a single method having a formal parameter Object [] ob is compiled, then the compiler cannot be sure as to which array type will be passed to ob by the calling function, and so IN THIS CASE, it can allow anything to be added to ob.

That would …

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

There is no Math.random method which takes a seed. Simply use the Random class and its nextInt(upperBound) method and you should be good to go. Also, before lighting up the buttons, make sure the previous state of all the remaining buttons is reset.

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

Do you have a package declaration at the top of your servlet? Does the "classes" directory contain the file "getname.class" placed in the folder hierarchy com/mmfsl/web ?

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

The second case is basically a free-for-all case which is still valid to support legacy code. You can do whatever you want with the passed in list. The first one is a valid usage of generics which allows traversal but not manipulation of the list.

So yes, to answer your question, the final byte-code generated is AFAICT the same with the restriction enforced at compile time.

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

Regarding bad titles: just report the first post of the thread and someone from the mod forums might fix that.

Plus, let's not go too off-topic here; how about wait for the OP to explain his/her situation (though I doubt it would happen).

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

The wildcard <?> is a shorthand notation for <? extends Object> hence the normal rules apply.

private void traverse(final List<?> lst) {
    final Object o = lst.get(0);
    lst.add(new Object());  // compile time error
}

This is the same reason why you can do a "get" but not a "set". The logic being, since the type parameter of R can be anything (or not known if you prefer it that way), setting any value might corrupt the state of the object since the actual type is not know. However, a 'get' is safe since any object can be assigned to the Object reference type.

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

No more than 30 mins without a break. If the entire premise is clear in my mind, it doesn't take a lot of time to churn out sizable amount of code. Plus given my short attention span, 30 minutes is a good enough time to keep me motivated.

Oh, but yes, I can watch anime for 4 hours straight. ;-)

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

Type information about a variable means the type of the object that has been assigned to that variable

Kind of; we are dealing with two concepts here: the real type of the object and the type of the variable to which the object is assigned.

List<Integer> lst = new ArrayList<Integer>();

Here, the entire code can play around `lst' blissfully without anyone knowing that the "real" type of object reference by the "List" variable is of type "ArrayList". Here the type of variable is List but the type of the actual object pointed is ArrayList.

That's why in the example u gave, the run time environment knew that "arr"'s type is Integer, and hence a String can't be passed to it. But why doesn't the compiler detect that ? Memory for the object is assigned at runtime, but the compiler KNOWS that the object's type will be Integer.

Consider this code:

public class Test {
    
    public static void main(final String[] args) {
        final Object[] arr1 = { "HI" };
        final Object[] arr2 = { 12.3 };
        if(positionOfStarsIsGood()) {
            doIt(arr1);
        } else {
            doIt(arr2);
        }
    }

    public static void doIt(final Object[] arr) {
        if(positionOfStarsIsGood()) {
            arr[0] = "HI THERE";
        } else {
            arr[0] = 666;
        }
    }
}

What do you propose the compiler should do in this case?

Also, technically, what is the relationship between a variable and its declared type called ? i.e. if Integer is called "type" of arr, then what is Object called of …

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

Does anyone know how to make the program wait for this command to complete before it moves onto the next lines of code?

Try removing the first two arguments from your string array i.e.

final String[] args = { "sudo cp", "/source/*", "/target" };

And preferably use ProcessBuilder class for running external processes.

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

My main concern is that like this, the harddisk is constantly being accessed for every single character - I'm sure it's highly inefficient.

Yes, it sure is.

Please note that when I used 'readLine()' instead of 'read()', i got the java heap error, so im guessing i have to read a character at a time.

Something's fishy here. The default buffer size of Buffered streams is AFAIK 8KB. Plus if you are looping over the input stream reading the bytes, encrypting them and writing them to a file, garbage collection should ensure that the bytes previously read are collected before throwing an OOME. Are you sure you are not keeping references to previously read data?

Actually it has to use the BufferedReader/Writer strictly.

Again fishy. The encryption algorithm doesn't know/shouldn't know the kind of content it is encrypting and hence it should have been BufferInputStream and BufferedOutputStream instead of its Reader/Writer counterparts unless you are using some sort of special encryption algorithm which operates strictly on textual data. :-)

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

How does the element type being available at runtime have anything to do with that ?

Because it enables fail fast behaviour. Array operations are checked at runtime since the type information is available to the JVM.

class Test {
    public static void main(final String[] args) {
        Object[] arr = new Integer[10];
        arr[0] = "WTH";
    }
}

/*output
Exception in thread "main" java.lang.ArrayStoreException: java.lang.String
	at Test.main(Main.java:4)
*/

BTW, there is a lot of controversy surrounding this decision of Java since some claim that if arrays were not covariant, no runtime checks would be required which would speed up code *but* at the cost of reduced flexibility. Another suggestion is to make arrays immutable which would always guarantee safe use of covariance feature. Rather than complicated things any further, simply put, when the author says that arrays are allowed to be covariant, it's simply because array stores are checked at runtime to prevent major screwups.

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

Anything isn't good or bad in an absolute sense. IDE's are a necessity when it comes to professional development since you get paid for each and every minute. The organization doesn't pay you to *learn* but to *develop*. But, when it comes to beginners, IDE's are notorious for making them lazy and taking things for granted.

You'd be surprised at the number of job applicants I've seen who can't name *five* methods of the class they have used all these years. I call these kids the "CTRL + SPACE" generation. :-)

jon.kiparsky commented: Amen +2
kvprajapati commented: Bookmarked! +11
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

then, at runtime, the generic variables are converted to Integer type. On the other hand, in

Nope; nothing is done at *runtime*. The 'T' in Mine assumes the type of the bound specified when giving the type parameter at class level. If no restriction is specified, Object is used.

Does this mean that whether the parameterized paradigm is followed strictly or not, depends upon the LHS of the reference assignment statement. Is this right ?

Yes; it is the declaration which matters since checks are done at compile time and not runtime but mixing things is never recommended (leaving out the type information in RHS) and the aim should always be to have a codebase with very few if not zero generics related warnings.

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

If you are working exclusively wrt manipulating strings, use StringBuilder class for appending operations rather than concatenation for strings. If you still face memory issues, then they might just be valid reasons and would require you to set the heap size accordingly. What is your current heap size?

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

Is your database running on the above mentioned port? Can you telnet to that port? As per this page (http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html), the URL should also include a database name which I don't see in your case.

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

Which directory are you executing this command from? Is your class inside any package? Try: java -classpath .:/home/prem/javaprograms/mysql-connector-java-5.0.8-bin.jar testsql

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

You have posted the javac command which you are using to compile your code. What is the java command you are using to execute your code? Are you properly setting the classpath when spawning your Java process?

Also, as already mentioned, move that mysqlconnection jar out of the JDK lib directory.

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

In the context of the OP's request to "move data with a large size from one object to another" in a performance-critical way, I didn't think that RMI would be relevant - but that was a judgement call, so YMMV. J.

I just wanted to make sure that the OP doesn't end up misunderstanding your contextual reply:

You can't send a ref between different JVMs [...]
If they really are different JVMs the your choices include a file or a socket connection

and ends up thinking that raw sockets or files are the only way of doing inter-JVM communication.

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

What is E once the program has been compiled ?

There is no type "E" after the class has been compiled. Generics in Java are based on type erasure and are compile time constructs i.e. your code is as safe as you want it to be. Deep down inside, all your "generic" variables are converted to Object types, unless you have a "bound" placed on your types in which case the variable becomes the erasure of that upper bound. This is one of the reasons why type declarations at the class level don't allow "super".

This is the reason why `nn1.set("Hello")` works while `String bb = nn1.get()` doesn't; a String is an object but an Object need not always be a String.

Another interesting thing to note is that the "E" needs to be stored somewhere since there are some reflection based methods added to the reflect package which deal with generics. (e.g. Field method getGenericType()). This is done by updating the class file format for Java 5+ and adding a new attribute "Signature" which stores this "generic" information present at the source level for querying purposes.

class Mine<T> {
    
    private T var;
    
    public Mine(T var) {
        this.var = var;
    }
    
    public void printInfo() {
        try {
            Field f = this.getClass().getDeclaredField("var");
            System.out.println(f.getGenericType());
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
    }
    
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can't send a ref between different JVMs

Yes you can (at least for custom classes) using RMI; moving refs between JVMs is the entire premise of the "distributed objects" theme. :-)

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

I think that processes as well as threads are given time slices

Yes, but "Thread.yield", as mentioned in your original post specifically refers to threads.

But still what is the difference between time slice and quantum ? I am not able to understand. They are synonymous in most literature (even in Wikipedia)

The terms are indeed used synonymously all over the internet. There was one message on some micro-kernel mailing list which jots down the difference (which again isn't very clear):

In short, the timeslice determines for how long a thread can
continuously occupy a CPU before being preempted, the quantum limits the
total time the thread may spend on the CPUs accumulated over all
occasions the thread was scheduled.

Maybe you should mail Neil (the original author of the article) or PM neilcoffey (the author of the article) on Daniweb for clarifications.

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

As far as I can make out, quantum is the total time that a process has to spend in order to complete

No, read the article again.

Each thread has a quantum, which is effectively how long it is allowed to keep hold of the CPU
[...]
a quantum is usually a small number of clock ticks, depending on the OS
[...]
a clock tick is typically 10-15 ms under Windows; under Linux, it is 1ms

BTW, yield is not about processes; it's about threads.

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

The explanation is on the same site.

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

Another thing I ran all the test without the wrapper can it be the wrapper is the problem?

It shouldn't be, but can't say; now your next target should be repeating the same tests (you know the usual routine) *with* the wrapper on the test machine.

since I change the ulimit on the server I see I get more connection around 300 plus with out any problem. Can it be this is tuning factor ?

Since the original code was missing an explicit close statement for the "Socket" on the server side, it might be the reason for all those CLOSE_WAIT state sockets. Since the limit is now 2048 (or whatever you have set), the CLOSE_WAIT connections get recycled *before* the entire process runs out of file descriptors (since it is now twice the original). But I'm not really an accomplished sysadmin :-); I'm just thinking of all the possibilities of what *might* have happened.

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

Yup, I guess we are all good to go. There are no stray connections here. BTW, have you changed the ulimit on this test machine? Is it still the default 1024?

Now all that remains is for the code on your production box to blow up so that you can deploy this new code. If it doesn't blow up, you are good to go anyways. :-)

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

I started out with C++ and never really understood it.

But you should, really. If not C++ (I admit C++ is a pretty complicated language when it comes to gotchas) then C and the basics of assembly programming to know *how* it works under the hood.

Does anybody know what that's called?

Programming with 'final' in Java to avoid destructive updates is kind of inspired by the "pure functional" languages where destructive updates are avoided. Another thing which can be achieved using final is immutability for your classes.

C# is a Windows thing (I'm almost positive)

No, it isn't.

and Python and JavaScript aren't precompiled at all.

Not entirely true, pyc files are the byte compiled version of your Python source file. Though something like this doesn't exist for Javascript ATM, I'm sure it isn't impossible. You have to understand that there is a difference between the language specification and its implementation though for most of the cases it would be safe to assume that you are talking about the standard implementation.

PS: Is Objective C is worth learning?

Depends on what you want to do with it?

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

... or making them learn the language top to bottom and develop an eye for flaws in the code. One or the other.

True; but language is something students would never have control over, at least those who are interested are bound to download a sane editor and work in it rather than following the footsteps of "notepad lovers".

I'm not sure as to why Smalltalk isn't the language which is used for teaching OO to students. Maybe teaching Java is a way of preparing the students for the enterprise world out there. ;-)

Emacs is on my TODO list but mastering vim comes first. :-)

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

Some universities make students code in Notepad/Wordpad. Asking students to use an editor which doesn't go syntax highlighting is a sure shot way of "frustrating" the hell out of students and making them hate the course.

I personally use Eclipse (work) / gvim (home).

BTW, it's not "JAVA" but Java.

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

If nothing, these certifications force you to have a closer look at the language in general, which you probably don't bother with unless you are studying for a certification.

Certifications have got a pretty bad rap due to the plethora of Software Engineers with certifications who can't do a hoot when asked basic questions or asked to write code. But grass root level certifications open up ways for more advanced (respected) certifications like SCWCD, SCDJWS, SCEA etc. Come to think of it, the description of certifications sounds very similar to a CS degree... ;-)

Bottom line: go for it if you can afford it (no point in burning cash in it if you have other things which require attention). If nothing else, it would at least bring you a bit closer to the details of Java programming language and will give you a upper hand when your resume is compared with those who haven't got one.

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

Actually the fixed code I just tested in test box. So far I have not move it to the real server. But so far there is no problem yet but never know when it can happen rite

Yes, but with the increased number of file descriptors, it should take a while for that to happen. If you are redeploying, make sure the latest changes go.

Yes I still have the CLOSE_WAIT after some times when the number of established touch around 240 then I notice there is CLOSE_WAIT.Other time there is none. This is what worries me what shall we do about it?

This needs more investigation. Now that we have seen that the output of lsof is satisfactory, we need to carry on the same exercise on your testing box for CLOSE_WAIT connections.

Restart the application on test box, get the netstat output just after starting the servers (not just the count but the entire netstat -nat output). Now repeat the same client test code which hits the server for 20 times and then again get the netstat output after some time (around 1 min). Paste both the outputs and the difference if you can. I'm not sure why there are CLOSE_WAIT connections here since the code makes sure that all the resources are released after a request is processed.

Thank you very much for your time and effort and knowledge I dont know how to say thank you to you.

You are of course welcome. …

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

Which tool are you specifically referring to here for creating web services? What kind of web service (JAX-RPC, JAX-WS, JAX-RS)?

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

Your question isn't very clear; when you say JDK tool, which tool are you referring to? Also, if you are talking of "java", it doesn't know the "fully qualified class name", you have to specify it. When you write:

java -cp . net.sanjayts.Main

the executable searches for the directory structure net/sanjayts in the classpath and executes the bytecode present in the net/sanjayts/Main.class file (if it exists).

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

Use the getResource() method of the ClassLoader class for loading resources in a location-independent manner relative to your classloader path. This path is normally the classpath which you set (-cp) when spawning the Java process.

This method is capable of loading any classpath resource, not just packaged resources. Hence you can either have a images directory which hosts the images or a "game.images" package. For e.g. lets assume that your JAR contains the entire folder structure for the class files based on the package name along with a images and sounds directory, something like:

JAR
  - pkg
    - spacewars
      - images
  - images (normal directory)

The methodology for loading the resources would stay the same:

final ClassLoader loader = getClass().getClassLoader();
final URL url = loader.getResource("images/one.png");
// OR
final URL url = loader.getResource("pkg/spacewars/images/one.png");

One suggestion: AFAIK, almost all games have the concept of "resource managers" which are contract (interface) driven classes which are solely responsible for loading game assets. For the time being you can have a singleton ResourceLoader class which loads the resources for you. This way you can abstract the resource loading and change the strategy your resources are loaded without a lot of pain. E.g. in the future you might want to pack your resources in a custom archive format and then read the resource from it. If you litter your code would all the getResource() calls, it might be a bit difficult and cumbersome to move to a custom archive format. But if you …

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

The results look good, at least no open streams/resources lying around. After fixing the code and increasing the file descriptor limit, have you faced any more "too many open files" error?

Also, have you checked the connection limit for your MySQL server or have you stopped getting those "out of connection" exceptions? Are you still getting super high values of CLOSE_WAIT after the clients start hitting the server?