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

When posting exceptions, make sure you include the full stack trace along with the "Line" on which the exception has occurred.

Anyways, I have highlighted the problematic part of the posted code:

if(temp.num<n)
      	{
          current= temp;
           current.rlink.num=n;
      	
		
			if(temp.rlink==null)
			 {
			  temp.rlink.num=n;
			  System.out.println("Inserted at the right"+current.rlink.num);
			 }

My comments:

  • current.rlink.num=n; : This part of code makes the assumption that the "current node" always has a right link which is non-null; this assumption is flawed. You don't even need this statement.
  • temp.rlink.num=n; : Again, this code is flawed since this piece is placed inside the IF check if(tmp.rlink == null) and hence will *always* cause NullPointerException.

When I say insert the value, you need to assign the "Node" object to rlink/llink instead of playing around with the "num" field. Like:

if(tmp.num < n) {
    if(tmp.rlink == null) {
        tmp.rlink = newNode;
    } else {
        tmp = tmp.rlink;
    }
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Hello sir thank you for the reply...but sir how can i put return my insertnum method is void?....

My point was that by doing early returns, you cut down the nesting depth. Also, just putting "return" is also valid and is in fact a well known method for breaking early.

if(isEmpty()) {
    root = newNode;
    System.out.println("Successfully inserted root node");
    return;
}
tmp = root;
while(tmp != null) {
    // remaining code
}

I am confuse also with my algorithm it is poor algorithm sir...i apologize i cant write my algorithm i just want to learn in this sir

I of course understand that and hence my suggestion to "write down the steps" so that you have the clarify of the implementation in your head before you go off to write the code. Anyways, you are almost there. You still don't handle the condition wherein a value is already present in the tree. Inside your "while", you need something like:

while(tmp != null) {
    if(tmp.num == n) {
        return; // value already present, break out
    }
    if(tmp.num < n) {
        // the new value should lie at the "RIGHT" of the current node
        // Is the right link for tmp NULL?
        //  if yes, then attach the new node to the right of tmp and print the message
        //  if no, then re-assign tmp as "tmp = tmp.rlink" and "continue"
    } else {
        // similar to above explanation; just replace "RIGHT" with "LEFT"
    }
}

Another point; why do …

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

sir i am confuse what variable should i re-assign my temp?

Reassign in the sense that since you want to continue traversing the tree and the "while" construct checks for the variable "temp", update temp accordingly based on the results of the comparison.

in this, If the tree is empty, insert the root node and return from the method

Just add a "return" statement after assigning a new node to the "root" so that you don't have to nest your remaining statements i.e. completely remove "else".

BTW, do you have an algorithm ready for this thing? This type of confusion normally happens when you don't completely understand what you are trying to implement. Write down the algorithm here which you are currently using to implement this binary tree.

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

You still are not following the steps 2 to 4 as mentioned in my previous post; read and understand them and get back if it still isn't clear.

The infinite loop is because you check "temp" for NULL and since "temp" is not re-assigned in the while loop, the while loop never breaks.

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

The error is because "newNode" is of type "Node" whereas "current.num" is an "int".

Also in your "insert()" code a few comments:

  • No need to explicitly set llink and rlink as NULL, they would anyways be NULL
  • If the tree is empty, insert the root node and return from the method
  • If the value of the newly inserted element is the same as the current node which is checked (temp), return again.
  • Also, you need to "re-assign" temp in your while loop so that you are always dealing with the appropriate node rather than always the root node.

Update your code and re-post again if it still doesn't work.

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

Use the Calendar class for performing Date related operations, esp the add() and set() methods. A sample snippet in Groovy:

import java.util.*

def c = Calendar.getInstance()
c.set(Calendar.DAY_OF_MONTH, 2)
c.set(Calendar.MONTH, 2)
// c now contains the date 2nd of March 2011
def i = 1
while(i <= 7) {
  c.add(Calendar.DAY_OF_MONTH, -1)
  println c.getTime()
  i++
}
OUTPUT:
Tue Mar 01 11:31:45 IST 2011
Mon Feb 28 11:31:45 IST 2011
Sun Feb 27 11:31:45 IST 2011
Sat Feb 26 11:31:45 IST 2011
Fri Feb 25 11:31:45 IST 2011
Thu Feb 24 11:31:45 IST 2011
Wed Feb 23 11:31:45 IST 2011

Use the SimpleDateFormat for converting the Date object to a desired representation.

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

This happens because you don't "search" for the appropriate parent node for the new node to be inserted. You'd need a solution which recursively or within a loop searches for an appropriate parent to whose left/right the new node would be inserted. Read the basic algorithm here.

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

Definitely strange that a fresh rewrite using Eclipse/Netbeans didn't work.

I can't speak for Netbeans but with Eclipse how are you creating a fresh project? Are you able to run a simple "hello world" code in Eclipse?

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

As an aside - It's probably just me not understanding you properly but I can't see why the protocol that you suggest would work. Even if the server knows the size of the file to be sent, the client socket cannot close after the file has been sent as it is waiting for a message from the server

Yes, you are right, the socket can't close after the file has been sent. *But*, the server now knows *how* much data is the "file" contents and how much data is "message" contents. So now you are saved from the infinite-loop condition since you have another condition you need to check for; the size of the data transferred. Something like this:

long fLen = /* read file length from the message */;
long totalLen = fLen;
int bytesRead = -1;
while(true) {
    if(totalLen < buf.length) {
        bytesRead = in.read(buf, 0, totalLen);
    } else {
        bytesRead = in.read(buf);
    }
    totalLen -= bytesRead;
    out.write(buf, 0, bytesRead);
    if(totalLen <= 0) break;
}

You helped me to understand what the problem was and even though I fixed it in a roundabout way, without implementing hybrid protocols

Does your existing code handle just the files sent from the client or even messages? If you are only transferring files, you really don't need a hybrid protocol. If your current code deals with both file contents and messages from client, I'd be interested in seeing how you managed to pull it off without having a demarcation between the …

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

I am having a problem implementing the protocol you suggested as I don't know how big the file will be from the client side

I'm not sure why it's that difficult; knowing the number of bytes present in the file is as simple as making a single method call on the File object you are anyways creating.

I'm assuming because it's still waiting for the client socket to close.

Right, because AFAIK, as long as the client socket stream is open, you'd never get a -1 when reading the stream. Also, the while loop condition should be >= 0 or != -1.

This didn't make any difference to the performance of the program

For this simple program, sure, it won't be a problem. But converting the data read into a String object and looping over it would surely take a hit when dealing with multiple clients and large files.

So, I was wondering... wouldn't it be possible to use the exception blocks to implement a fail safe option? In other words, instead of sending a success message, write code within the client catch block and server catch block that would account for any problems with the socket. Surely, if there are problems with the socket then one can assume that the information was lost somehow in transit and steps could then be taken to remedy the situation. Then I wouldn't have to implement hybrid protocols at all.

You lost me there with the "problems with socket" bit? …

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

> "Flag bad post"

In case you want to rectify something you posted (of course given it follows the rules) after the 30 minute edit time frame or you have a duplicate post which you want to flag for deletion.

> "Post Reply"

You want to quote yourself or add to the contents of your previous post after the 30 minute edit time frame.

:)

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

If you plan on making your Vector3 class immutable, you have no option but to "return" Vector3 from your "multiply" method.

Without the restriction of immutable classes, it would be as simple as modifying the state variables of that given instance; you don't even need "v3".

public void multiple(int x) {
  this.num1 *= x;
  this.num2 *= x;
  this.num1 *= x;
}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What do you mean by "call back"? The simplest and the logical way would be to change the return type of your method to "Vector". Some other approaches would be to pass in a reference to Vector and update the Vector in your "multiply" method or have a static member in your main class but then again not recommended.

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

Does garbage collection occurs in PERM Area of Java Heap ?

AFAIK, yes.

This aspect doesn't come into play a lot when doing regular development and using already existing libraries but becomes apparent when you implement custom classloaders and manage class loading dynamically.

One e.g. would be Tomcat servlet container. Let's assume that Tomcat creates a separate "classloader" for each web application deployed. If out of the many running web apps if one of the web apps is stopped, the corresponding classloader goes out of scope along with the objects/classes created/loaded using that classloader. If now, for some reason a permagen GC is triggered, the classes along with the classloader would now be garbage collected. If you run the JVM with the -verbose:class switch, this can be easily confirmed by the log message "Unloading class somepkg.xxx".

kvprajapati commented: :) I'm looking forward to seeing more great stuff from **your** blog posts. +12
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IMO implementing hybrid protocols has always been a problem.

Just thinking out loud here but it seems that in your case the server has no way of knowing when the "file transfer" has completed and the user now wants to pass across a string message to the server. Also, I don't think the "while" loop at the server end would "terminate" unless the client socket output stream is closed (which would in turn trigger -1 being read thus breaking the loop).

My suggestion would be to implement a small protocol between the client and the server in which the server knows "how much" binary data the client would be sending thereby giving the server a logical condition to break out of the loop. An example of this protocol would be (all messages termiated by line breaks):
BIN:1024 (client would now initiate a binary transfer of content length 1024 bytes)
TXT:1024:UTF8 (client would now initiate a text content transfer of size 1024 byes and encoding being UTF8 -- which would be anyways default in case it is ignored)
DIE (client has decided to quit; the server can now safely close the client socket)

An alternate solution would be to use RMI in case the client/server would always be JVM bytecode compatible and the use of raw TCP sockets is not a requirement.

EDIT: As far as your code is concerned, I'm personally not a big fan of exposing variables to a greater scope than …

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

You need to tell us:
* The directory structure
* The command you are executing on the command line

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

You can place the JAR file anywhere, just make sure you provide the full JAR path when specifying the classpath for the java command.

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

The PATH environment variable is typically used by OS to find executables so that you can simply do "javac SomeFile" instead of "/usr/bin/jdk/javac SomeFile". The classpath is a Java specific property which tells the VM where to find all the necessary class/JAR files. (There is also a CLASSPATH environment variable which again shouldn't be messed with; there are better ways around it like setting classpath when firing javac or java).

In your case, you simply need to "set the classpath" when "invoking the java command". E.g. java -classpath mysql.jar:yourapplicationjar pkg.Main

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

Like already mentioned, tell me how do you exactly launch the application right now. Use the template provided in my previous post to launch your application by setting the appropriate classpath.

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

i know the method will be the same and both will essentially do the same thing. but why two ways to initializing arraylist?

The second form is called "programming to an interface". Any further use of "myList" in your code would adhere to the "List" interface and as such would allow you to change the implementation class by just changing a single line.

This distinction plays an important role when it comes to designing an API since you wouldn't really want to bind your users to a specific implementation which might change in the future. Establishing a common interface (by using either Java interfaces or super-classes) helps when it comes to re-factoring and writing unit tests.

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

How are you launching the application? Make sure that the driver JAR is listed in the classpath when you launch the application and you should be good to go.

java -cp app.jar:mysql.jar your.pkg.MainClass

Also, never ever mess with your default JDK installation. If your application requires a third-party JAR, supply the same using the -cp switch when compiling and running Java programs rather than "pasting" JARs to the JDK directory.

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

By statements do you mean "code"? If yes, then JProfiler which is included with JDK 6 can be used for CPU profiling and at the end of the run gives the total time taken by each method till now. Search around for CPU profiling JProfiler.

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

SerializedThread is an inner class i.e. a class which depends on some outer parent class i.e. there is an association between your class Main and SerializedThread. When you try to serialize SerializedThread, it also tries to serialize Main class (which doesn't implement Serializable) hence the error.

A couple of solutions: make the main class implement Serializable (not recommended) or move the SerializedThread out of Main (recommended).

Alex_ commented: solved +3
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you've just started out with Java, give the forum sticky (by yours truly ;-)) a read. It's a decent intro (jam packed with information).

If you are looking to get started in a quick and dirty way, nothing beats the official tutorials (click on the Getting started link).

BTW, if your question/query was resolved, please click on the "Mark this thread as solved" button at the bottom of this thread. Good luck.

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

In your source code i.e. Main.java file change class HelloWorld to class Main .

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

The name of your class should be the same as the name of your Java file i.e. Main.

~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

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

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

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

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

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

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

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

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

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

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

AFAIK, `bind` accepts a tuple; just wrap those HOST and PORT in another pair of parentheses and you should be good to go.

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

Reason: not getting desired result. sorry I really tried.:)

You can always "view" what you have written by pressing the preview button. Given that you are learning, it would be worth it to *never* type out your responses in the "quick reply" editor (the small text area which you see at the bottom of every thread) and always use the "advanced editor" (Use Advanced Editor) button below the text area.

Pro tip: Don't try to take in all of it at once. Learn about one thing at a time. Thinking of too many things would have the end resulting of just confusing you, nothing else. Good luck. :-)

Agapelove68 commented: You are absolutely right. This was confusing me and didn't let me edit before 30 min were up. Thank you for your encouragement! :) +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

tell me if there are any other commands other than rcp and scp .

You can try `rsync`. Assuming you want to transfer files from server 1 to server 2:

rsync -avz user1@server1:/src/path/ user2@server2:/dest/path

You can ignore the user@host syntax for a particular server if you are already logged to that server. The above command basically "syncs" the files from 'src/path' directory on server1 to 'dest/path' directory of server2.