Bottom line: instance fields can't be used from static methods (which is what main is). An easy solution for this pair of classes would be to make the fields static. While that would be OK to make this example work, it would be the wrong solution once you integrate the code into the overall codebase. But the problem wouldn't manifest there, because you wouldn't have static methods.
posted 1 week ago
I must point out that I have a very narrow and limited knowledge of the java language
I only understand a very small portion of its workings
I understand that I need to make some changes to the code which you posted and which works as a stand-alone example, before I can incorporate it into my java program
I think that I need to remove the word 'static' and the word 'main' but that's it
So am floundering due to lack of knowledge
posted 1 week ago
Some progress to date..................................
Added the word 'static to both classes (Socket Server and Socket Client) code
Clean compile on Socket Server code but
1 compile error on the Socket Client code
reference to Trading_Decision_2 (original line 68)
error] cannot make a static reference to the non-static field Trading_Decision_2
which is a variable calculated earlier on in the large java program
what changes do I need to make to the variable Trading_Decision_2 ?
Seeing as you have put a lot of effort into this, I'll make an exception to our rule and post the full code of client and server that use no static fields. There's a static main method, but that's just for testing.
In the server code, the important lines are 9 and 10, which you need to incorporate into your larger code. On the client side, it's lines 16 and 17.
The code completely punts on error handling, which obviously your code can't do once you put it into use.
The other issue is that the server waits until "exit" is sent before returning. So you can't call it from the main thread of your larger app, as it would block it. It needs to be called from a background thread.