Porting C file read/write program to Java

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon Wigzell

    Porting C file read/write program to Java

    I recently wrote a program with MS Visual Studio C++, sent it off to the
    client where it didn't run, after some probing I discover they are on a Mac!
    My program is a MSF interface that is really only 2 File buttons with
    corresponding text fields. The actual guts of the program is a C file that
    accepts 2 file names as arguments and reads from one file, manipulates the
    string and writes it to another file. Java and C syntax are very similar.
    Does anyone know of a simple and free (or trial) java compiler and interface
    builder they could recommend? Can Java do this job e.g. read and write files
    and let me program and compile it on my PC and then be run on the clients
    Mac? Any other thoughts or suggestions on this before I go ahead with it?


  • Brad BARCLAY

    #2
    Re: Porting C file read/write program to Java

    Simon Wigzell wrote:[color=blue]
    > I recently wrote a program with MS Visual Studio C++, sent it off to the
    > client where it didn't run, after some probing I discover they are on a Mac!
    > My program is a MSF interface that is really only 2 File buttons with
    > corresponding text fields. The actual guts of the program is a C file that
    > accepts 2 file names as arguments and reads from one file, manipulates the
    > string and writes it to another file. Java and C syntax are very similar.
    > Does anyone know of a simple and free (or trial) java compiler and interface
    > builder they could recommend?[/color]

    Sun has always gave their JDK's away for free. Go to
    http://java.sun.com to download.

    On the other end, they'll probably need to go to http://www.apple.com
    to get an Apple Java Runtime Environment, if they don't already have one
    installed.

    One note: while the basic syntax of Java is similar to C, Java is
    _not_ C. Java is Object-Oriented. It has its own API that has no
    similarity to any of the standard C APIs. You shouldn't have too hard
    of a time learning the language, but don't think for a second that this
    is going to be a simple "cut, paste, and change a few lines of code in
    the header" task.
    [color=blue]
    > Can Java do this job e.g. read and write files
    > and let me program and compile it on my PC and then be run on the clients
    > Mac? Any other thoughts or suggestions on this before I go ahead with it?[/color]

    Of course. Java is write-once, run anywhere. There is no problems
    with you compiling your Java class files on a PC and running them
    anywhere else -- that's the whole point of Java (well, one of the big
    ones at least :) ). And file I/O is a pretty basic operation in Java --
    the "java.io" package contains everything you'll need to open files and
    work with data in structured and unstructured streams.

    HTH!

    Brad BARCLAY

    --
    =-=-=-=-=-=-=-=-=
    From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
    The jSyncManager Project: http://www.jsyncmanager.org

    Comment

    • Simon Wigzell

      #3
      Re: Porting C file read/write program to Java

      Thanks, I'll give it a bash...

      I had heard that Java is actually "Write Once, Debug Many"...we shall see!

      SignatureSimon Wigzell Dynamic Websites from : Virtual Cottage Industries
      (250) 656 5867
      "Brad BARCLAY" <yaztromo@filte r.jsyncmanager. org> wrote in message
      news:_QdWa.3277 2$hOa.2358@news 02.bloor.is.net .cable.rogers.c om...[color=blue]
      > Simon Wigzell wrote:[color=green]
      > > I recently wrote a program with MS Visual Studio C++, sent it off to the
      > > client where it didn't run, after some probing I discover they are on a[/color][/color]
      Mac![color=blue][color=green]
      > > My program is a MSF interface that is really only 2 File buttons with
      > > corresponding text fields. The actual guts of the program is a C file[/color][/color]
      that[color=blue][color=green]
      > > accepts 2 file names as arguments and reads from one file, manipulates[/color][/color]
      the[color=blue][color=green]
      > > string and writes it to another file. Java and C syntax are very[/color][/color]
      similar.[color=blue][color=green]
      > > Does anyone know of a simple and free (or trial) java compiler and[/color][/color]
      interface[color=blue][color=green]
      > > builder they could recommend?[/color]
      >
      > Sun has always gave their JDK's away for free. Go to
      > http://java.sun.com to download.
      >
      > On the other end, they'll probably need to go to http://www.apple.com
      > to get an Apple Java Runtime Environment, if they don't already have one
      > installed.
      >
      > One note: while the basic syntax of Java is similar to C, Java is
      > _not_ C. Java is Object-Oriented. It has its own API that has no
      > similarity to any of the standard C APIs. You shouldn't have too hard
      > of a time learning the language, but don't think for a second that this
      > is going to be a simple "cut, paste, and change a few lines of code in
      > the header" task.
      >[color=green]
      > > Can Java do this job e.g. read and write files
      > > and let me program and compile it on my PC and then be run on the[/color][/color]
      clients[color=blue][color=green]
      > > Mac? Any other thoughts or suggestions on this before I go ahead with[/color][/color]
      it?[color=blue]
      >
      > Of course. Java is write-once, run anywhere. There is no problems
      > with you compiling your Java class files on a PC and running them
      > anywhere else -- that's the whole point of Java (well, one of the big
      > ones at least :) ). And file I/O is a pretty basic operation in Java --
      > the "java.io" package contains everything you'll need to open files and
      > work with data in structured and unstructured streams.
      >
      > HTH!
      >
      > Brad BARCLAY
      >
      > --
      > =-=-=-=-=-=-=-=-=
      > From the OS/2 WARP v4.5 Desktop of Brad BARCLAY.
      > The jSyncManager Project: http://www.jsyncmanager.org
      >[/color]


      Comment

      • Phil

        #4
        Re: Porting C file read/write program to Java

        I thought that MS VS C++ had "#ifdef MAC" like stuff that you could
        use, the library source code uses it.


        "SPC" <steve@scholl.d emon.co.uk> wrote in message news:aa6c6bcb.0 308032233.5e8df 3c7@posting.goo gle.com...[color=blue]
        > I'd recommend using Eclipse as your IDE. www.eclipse.org. With a
        > program as simple as you describe, it really is write once, run
        > anywhere. The more complex things get, the more testing you'd need to
        > do on the target platform. As someone else has said, you'd need to
        > make sure that your customers have the appropriate JRE downloaded and
        > installed.
        >
        > Steve
        >
        > "Simon Wigzell" <simonwigzell@s haw.ca> wrote in message news:<VMbWa.570 196$ro6.1294859 4@news2.calgary .shaw.ca>...[color=green]
        > > I recently wrote a program with MS Visual Studio C++, sent it off to the
        > > client where it didn't run, after some probing I discover they are on a Mac!
        > > My program is a MSF interface that is really only 2 File buttons with
        > > corresponding text fields. The actual guts of the program is a C file that
        > > accepts 2 file names as arguments and reads from one file, manipulates the
        > > string and writes it to another file. Java and C syntax are very similar.
        > > Does anyone know of a simple and free (or trial) java compiler and interface
        > > builder they could recommend? Can Java do this job e.g. read and write files
        > > and let me program and compile it on my PC and then be run on the clients
        > > Mac? Any other thoughts or suggestions on this before I go ahead with it?[/color][/color]

        Comment

        Working...