Hello, am new to the real programming but i have very much interest.
As a first real java project am trying to develop a P2P network application which can be used for chatting, but the problem is:
Should it load as a server.and if so how do i get it to listen for connections and read any incoming input stream, b'se when I try putting the server code in the GUI interface constructor, it keeps throwing the socketexception:socket not connected. I dont know how to listen before any client connects and yet get the input. Anyway, am just confused right now. Some one just bail me out.
Thanx.

Hello Sitajaf, nice to meet you :D
You should try to find answers from "Software Development" > "Java"
Good luck!

When I try to launch my JNLP file, I get the following error:

MissingFieldException[ The following required field is missing from the
launch file: (|||)]
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Quote ...
how to listen before any client connects
Use the ServerSocket class.

sigh, whats this information gonna help the oke, we are trying to help him not confuse him.

ObjectOutputStream output;
ObjectInputStream input;
ServerSocket server;
Socket connection;

private void waitForConnection() throws IOException
    {
        
        displayMessage("waiting for connection");//note displayMessage is an own Created method
        connection = server.accept(); //allow server to accept connection\\server = server socket\\connection = socket
        displayMessage("connection " + counter + " recieved from: " + connection.getInetAddress().getHostName());
    }   //end method waitForConnection

   


    private void getStreams() throws IOException
    {
        //set up output streams for objects
        output = new ObjectOutputStream(connection.getOutputStream());//output = ObjectOutputStream
        output.flush();

        //set up input stream for objects
        input = new ObjectInputStream(connection.getInputStream());//input = ObjectInputStream

        displayMessage("\nGot I/O streams\n");

    }   //end method getStreams

this is more or less what you should work towards, but this is only 1/3 of the code needed to make a chat server, its just an expample

krefie

Thanx, krefle. Am see looking it.
To: (Why not use normal Java Compiled files even Jar files?)
What java compiled files? Its a desktop apllication

Thanx, krefle. Am looking at it.
To: (Why not use normal Java Compiled files even Jar files?)
What java compiled files? Its a desktop application

Edited 6 Years Ago by sitajaf: n/a

JNLP uses Java webstart and it is better to use jar files for desktop application,
use javac compiler to make class files that can be bundled into jar file.

IDEs like Netbeans or Intellij Idea will easy your work

Edited 6 Years Ago by Stefano Mtangoo: adding link

This section covers some common problems that you might encounter when developing and deploying Java Web Start applications. After each problem is a list of possible reasons and solutions.

Problem: My browser shows the Java Network Launch Protocol (JNLP) file for my application as plain text.

Most likely, your web server is not aware of the proper MIME type for JNLP files. See the Setting up the web server section for more information.

Furthermore, if you are using a proxy server, ensure that the update versions of the files are returned, by updating the time stamp of the resources on the web server such that the proxies will update their caches.

Problem: When I try to launch my JNLP file, I get the following error:

MissingFieldException[ The following required field is missing from the
launch file: (|||)]
at com.sun.javaws.jnl.XMLFormat.parse(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.jnl.LaunchDescFactory.buildDescriptor(Unknown Source)
at com.sun.javaws.Main.launchApp(Unknown Source)
at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
at com.sun.javaws.Main.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Often this error occurs when your XML is malformed. You can stare at the code until you figure it out but it is easier to run an XML syntax checker over the file. (NetBeans IDE and jEdit both provide XML syntax checkers.)

However, this error can occur in a other situations and the above was caused by the following line in an otherwise well-formed XML file:

<description kind="short">Demonstrates choosing the drop location in the target <code>TransferHandler</code></description>

The error was caused by the illegal embedded code tags.

I would not bother with JLNP for my any desktop apps unless there is compelling reason to use it (Which I don't see for now)

But can you create the jar file form an empty application. i think one needs an application that is already compiled and able to run. Then that is when you can bundle it into one file. That is if am understanding u clearly.
What i was asking for was the help in coming up with the application and not bundling the final application.

I have made simple googling as I'm yet to do any chat app.
But basically here are steps
1. Create server.
2. Create client (Both are sockets classes)
3. server is listening to a port
4. Once request is made by client, server creates thread to serve that server and add the ID/Name of the accepted connection in list of active clients
5. Server will have a method to connect two threads in active list

That can be done in many way but I would advise you to start with understanding ABC of TCP/IP then Java sockets tutorial and then, choosing design to implement will be easier

This question has already been answered. Start a new discussion instead.