When you upgrade Caché from any previous version, every time you should look at Upgrade Checklist in the documentation, and this checklist while upgrade from such old version as 5

And even with just a search by documentation you may find this link, with a text

SPOOLER Heading Processing Changed
In this version, a number of changes have been made to the HEADING and FOOTING statements, and general printer/terminal output in this context. Applications that depend on the format of SPOOLed output should be carefully checked to make sure the output still conforms to expectations.

in your code,

obj - it is some object, it may have some ID or not, if it just created

name1 - it is a value for property name in that object

but I completely don't understand why is here name2 and name3, and what do you suppose should be happens after this line ?

and how it should save data in other objects which we even don't know which ?

you should know somehow which objects you want to update. If you know only some other properties, you can use SQL command UPDATE 

Please forget about old-way programming. We now have so many features out-of-the-box which helps write understandable code quite easy.

set fs=##class(%Stream.FileCharacter).%New()
set fs.Filename="c:\csvfile.csv"
while 'fs.AtEnd {
  set line=$listfromstring(fs.ReadLine(), ",")

  #; in line you will get listbuild for all columns in a row
​}

class %Stream.FileCharacter helps to read text files, which may contain text in different codepages, and line ends.

Or if you need to read some binary data, which should have some conversion on the fly, use %Stream.FileBinary.

I've already answered for exactly the same question at google groups

In first you should look at the official documentation which is available online here
You have very old system, so you should install new version of Ensemble at new windows server. Installation Guide 

And copy all of you data from old server to new. But it is may be very difficult task, without knowledge about your application.

As well you should look at Cache Upgrade checklists archive and latest, and Ensemble Release Notes

I've used Delphi so long ago, and could be mistaken. But to be sure that application is not interactive, it should not have any visual components. And as I remember you should start developing from Console Application. To check that actually it does work correctly, you may try with real console tool, something like: dir, md, etc.. You may try this $zf(-2,"dir > testdir.txt"), if after executing this code testdir.txt file will appaer with content for some folder, you'll see that it's work. And it means that in your application should be changed something to be as console application.

Looks like, you do not know about %Installer.Manifest.  You can use it in any different ways, be it installation new application or just simple changing instance's settings. With this manifest I'm building installation archive with project, it includes deployed code some data, and web sources. I'm installing new server with it, manually, or even with docker. And you can use internal Task Manager to run this installation by schedule automatically. You may also look at this project - GitHubCI, it helps to deploy application automatically just after commit to your github repository.

You can look at the documentation here online

and excerpt about custom installation

The Caché installation program allows you to select certain Caché components to be installed on the computer. For example, you may want to install only the Caché SQL Manager. Keep in mind that some selections require that you also install other components.

and about standard installation

The standard installation procedure installs both Caché server and client components on the computer.

I did not show how you made connection to the Caché, and looks like, your Java application has hardcoded login password which used to connect to server. 

so, I may only suggest, that you use code like this

Class.forName ("com.intersys.jdbc.CacheDriver").newInstance();
CacheDataSource ds = new CacheDataSource();
ds.setURL("jdbc:Cache://127.0.0.1:1972/SAMPLES");
Connection dbconn = ds.getConnection("_SYSTEM","SYS");

Last string is Caché login password, so you should use here user's login and password. Any works from your application should be with user's login.

Why do you name it macro ?
Maybe you mean MAC routine ?

I highly recommend to read this tutorial about CacheObjectScript

usually you can call routine by simple command

do ^routine

but sometime you need to call directly to concrete label in that routine

do label^routine()

but in this case if you use curly brace style, you should public such method in routine

label() public {
 write "Hello World!"
​}

or in old style

label()
 write "Hello world!"
 quit

So, you had to start with such explanation.

Well, does not matter what do you set in Accept header, if you don't use it by yourself. Like, you should check incoming content type and send an error if it is not accepted. This Header change nothing in incoming data,  if data was sent in another format.

To read data, you should know that %request has three different ways for getting data. You have already known in %request.Content, which usually contains binary streams. Then %request.MimeData, and %request.Data, it is a Multidimensional properties, and %request has some getters for them, %request.GetMimeData and %request.Get. MimeData, needs when client send data in multipart mime format, such as several files or so on. And %request.Data, in all most cases, and you should look at this property and method %request.Get("somename")