12/15/2021»»Wednesday

Java To C Language Converter

12/15/2021
    11 - Comments

Tools to Convert Java to C# Source Code. Below are some of the tools that can be used to convert the code from Java to C#. This is a Eclipse plugin for developing for multiple platform using single code base. Know more about Sharpen here. The Web Code Converter provides a quick easy way to convert HTML, DHTML, JavaScript, CSS and other web based languages into JavaScript, TypeScript, VBScript, LotusScript, ASP, PHP, JSP, Ruby, Rebol, Lisp, C#, Perl, and Python. It also converts Text documents to HTML. Pasting code into the textarea and clicking the Convert button instantly. Automated Conversion of Ada Language Applications to C/C or Java Ada-C/C Changer is the most reliable and powerful Ada language conversion solution on the market. With its Modeling and Re-factoring capability, Ada Changer not only modernizes the code by converting it to a modern language but also improves the code. Yes: My company (develops a Java compiler front end that includes an optional C-generating back end. However, there are some significant.

Java To C Language Converter

Assembly to C General Product Selection

Online

C++ To Java Convertor

(Please click here for a printable version of this page.)

ASSEMBLY Translators data sheets

ASM51C - INTEL ASM51 to C Translator Converter
ASM360C - IBM ASM360 to C Translator Converter
ASM370C - IBM ASM370 to C Translator Converter
ASM390C - IBM ASM390 to C Translator Converter
HLASM390C - IBM High level Assembler langauge HLAL390 to C Translator Converter
ASM68C - MOTOROLA ASM68xx (ASM6800, ASM6801, ASM6805, ASM6809, ASM6811) to C Translator Converter
ASM68K2C - MOTOROLA ASM68K (ASM68000, ASM68010, ASM68020, ASM68030, ASM68040) to C Translator Converter
ASM86C - INTEL ASMx86 to C Translator Converter
MASM2C - MICROSOFT MASM to C Translator Converter
PPC2C - MOTOROLA PowerPC to C Translator Converter
PWR2C - MOTOROLA Power to C Translator Converter
TASM2C - BORLAND ASMx86 to C Translator Converter
RASM2C - MOTOROLA RASMxx (RASM00, RASM01, RASM05, RASM09, RASM11) to C Translator Converter
Intel2At&t - intel x86 assembly to At&t assembly Translator Converter
At&tl2Intel - At&t assembly to intel x86 assembly Translator Converter
Z80toARM - Z80 assembly to ARM assembly Translator Converter (call if interested)

ASSEMBLY Translators data sheets in printer-friendly format

ASM51C - INTEL ASM51 to C Translator Converter

  • ASM68xx (ASM6800, ASM6801, ASM6805, ASM6809, ASM6811.)
  • ASM 68k (ASM68000, ASM68010, ASM68020, ASM68030, ASM68040.)
  • ASM 86
  • MASM
  • POWER (Translation Service by MPS only)
  • Power PC (Translation Service by MPS only)
  • RASM
  • TASM
  • HP 6400 ASSEMBLER 8088/8086
  • HP B1449 ASSEMBLER 8086/80186

Please note that if you cannot find your exact dialect listed above, we may be able to modify an existing tool to suit your needs (in fact that is how many of our tools were originally developed). We will select the closest translator to your dialect and use it as a base line. Then, we will modify the front-end of the translator to accept your dialect. Give us a call or send us a small sample of your code so we can estimate the modification costs involved in creating a translator that will work for your source code.

General Description

Our Assembly translators are Microsoft Windows source to source compilers that translate the Assembly dialect of your choice to your chosen target language (C, C++, C#, JAVA or J#). The turn-key translation process requires minimal user intervention and little to no knowledge of the source or the traget language. The translator output source code is in your target language, and ready to be tested with the target compiler. The comments are moved transparently from the source file to the target file. Any built-in functions for math, string manipulation and I/O in Assembly are converted to calls to external procedures (see sample translation).

The translator contains a syntax analyzer, a dialect-specific Assembly to tertiary converter, and a tertiary to target language converter. The syntax analyzer scans the input file for syntactic errors and generates a listing file of the program. Any syntactic errors are flagged with detailed English messages in the listing file. If no errors are encountered, the syntax analyzer generates an abstract syntax tree (AST), and the AST is converted to our proprietary tertiary language. This tertiary file is checked, and if no errors are detected, it is converted to your target language. Command line controls are provided to allow translation even when there are errors in the original source file. This is helpful when translating code fragments that are not complete programs.

The transformation of the AST into an intermediate tertiary language ensures the logical equivalence between the source and target languages. This proprietary tertiary language, which is common to our entire family of translators, allows correct mapping from the source language to the target language. The tertiary language is automatically converted to your target language while maintaining the logical equivalence between the output program and the input Assembly program.

  1. Simple to use, automated process
  2. Translation of fragments
  3. Translation of INCLUDE or COPY files
  4. Translation of directives
  5. Support for card format input
  6. Extensive error checking diagnostics
  7. Accurate translation
  8. Run time interface
  9. Easy to install

Translation Tools Pricing

Our most recent pricing information for translation tools can be found here.

Translation and Verification Services

To the extent that you want to outsource part of your translation process, MPS can provide you with translation and verification services. Our most recent pricing information for translation and verification services can be found here. However, if you would prefer to outsource your entire translation process, the use of one of our translators by your IT consultant can save you significant time and money in relation to manual translation. IT consultants purchase a number of our tools on behalf of their clients, and we are happy to work with them to get you the best translation results possible.

The MPS Advantage

Use of MPS' automated translation tools can help you save time and money and reduce error rates relative to manual translation. It also allows you to maintain complete security and control over your applications by keeping the translation process in-house. In addition, we fully guarantee our translation tools so that if, for any reason, you are not fully satisfied with the output of the tool you purchased, we will credit the full value of the purchase price towards our translation and verification services to get you the results you need.

About Micro-Processor Services

MPS is a known and trusted provider that has has been providing legacy software translation tools and consulting since 1976. We service only those companies that have the most exacting requirements for security, efficiency and cost-effectiveness, including various U.S. government agencies, the military, all of the leading aerospace and defense contractors, and hundreds of publicly-traded technology, telecommunications, industrial and manufacturing companies (please see our extended customer list). In addition, many of our biggest clients are IT consultants who purchase our tools on behalf of their clients. For more information please refer to our web site or contact us.

Abstract : The purpose of this report is to document someof the technical aspects of creating Java interfaces for codes written in languages other than Java. We outlinea procedure where one separates the construction of the interface from the external codes with the introductionof an intermediate 'wrapper' class. This intermediate class serves to isolate user interface detailsfrom the details of calling external routines. This intermediate class also facilitates the incorporation of externalroutines into Java based systems for distributed computing and/or visual programming.

Contents

  • The program written in 'another' language.
  • The Java class that encapsulates the C, C++ or Fortran code components.

These software components were developed in conjunction with the research supported by Air ForceOffice of Scientific Research Grant F49620-96-I-0327and National Science Foundation/ARPA Grant NSF-DMS-961584

Introduction

While people are debating whether or not Java is good for computationally intensive tasks, the fact is thatC, C++ and Fortran are the primary languages for those who do scientific/technical computing. It also seems unlikelythat this situation will change in the near future. Unfortunately, C, C++ and Fortran do not contain (as Java does)standardized and platform independent constructs for creating user interfaces, managing threads, networking, anda variety of other tasks associated with creating 'applications'. Thus, there is interest in creatingapplications in which the user interface, or other 'application packaging', is written in Java, but thecore computational component is written in C, C++, or Fortran (see Figure 1). The purpose of this document is todescribe, principally by means of an extended example, the process of creating a Java interface for a program writtenin C, C++ or Fortran.

In order to create applications which have the form indicated in Figure 1, one needs to know how to write Javainterfaces and how to call routines written in C, C++ and Fortran from Java. The process of writing a Java interfaceis well described in a variety of books [1][2][3] [4] and we will assume that the readeris capable of writing a modest Java interface which accepts input and displays output to a user. The task of callingroutines written in C, C++ and Fortran from Java comes under the heading of implementing and using 'native'methods. Here too, other documents [1][7] describe the process of interfacing Java toother languages. While, for completeness, we will outline the steps required to create and implement Java classeswith native methods, we assume that the reader has implemented a Java class that has at least one native methodprocedure in it (e.g. the 'Hello World' example of [7]).

In one aspect, this report is the presentation of an extended example demonstrating how this knowledge of writingJava interfaces and implementing native methods can be combined to create a Java/'other language' application.In addition to providing samples of the mechanisms for data exchange, the example also reveals the choices we made(and choices you will have to make) concerning the dividing line between the Java interface and routines writtenin C, C++ or Fortran. Our example concerns the creation of a Java interface for a program which solves the heatequation in a two dimensional rectangular region. Examples in C++ and Fortran are given (as is readily seen theC++ example is very close to what might be composed in C).

In the first section we outline the process that we follow for creating applications of the type described byFigure 1. In the second section we present the example which will form the basis of our discussion, and in thethird and fourth sections we detail the construction of the Java classes which form the primary components of theapplication.

The process of creating a Java interface to C, C++ and Fortranroutines

The process that we use for creating Java interfaces consists of the three steps indicated in figure 2.

A noticeable feature of the process is that we utilize three steps, rather than two. One may wonder about theneed for the intermediate step; that of writing an intermediate class that ``wraps' the C, C++ or Fortran code.Originally we didn't have three steps, but adopted this practice for several reasons:

  • It facilitated having the external code run as a separate thread. If one is running a computationally intensive task, then this allows the task to be executed without ``freezing' the interface.
  • By using this intermediate class we have isolated that component of the application which contains inter-language calls. Since the inter-language calling procedure for Java is evolving, this allows us to accommodate any changes in the inter-language procedures more easily. Additionally, by not embedding this code within a user interface, we also allow the user interface to change independently (this is important because the Java user interface classes are evolving as well).
  • Lastly, and no less importantly, this class provides an encapsulation of the external routines which facilitates their incorporation in a visual programming system or a software infrastructure which supports distributed computing.

The example program written in 'another' language.

The starting point for the process of writing a Java interface is to have a program or a selected set of codecomponents that one wishes to write interfaces for. Rather than discuss the process of writing interfaces in anabstract way, we discuss the process of writing interfaces for a specific example. The example program is one thatcomputes the evolution of the temperature of a rectangular plate. The main driver routine is given below (as wellas in the file tempCalc.cpp); the include file for the functions which the main routinecalls are given in tempCalcRoutines.h and the source for these routines is givenin tempCalcRoutines.cpp.

Java To C Language Converter Free

In the first part of the main routine, the problem and run parameters are set, memory is allocated and the temperaturedistribution is initialized. A time stepping loop is then executed. In this loop, the temperature of the plateis evolved in time increments of size dt by calling the routine evolveTemperature(...) and at some predeterminednumber of time steps the temperature distribution is output. (In this case written to a file tempOut.dat).

Even though the temperature values are associated with a two-dimensional set of nodes covering the plate, weallocate and pass one-dimensional arrays of values. This was done because the standard method for exchanging datawith other languages is through one-dimensional arrays; Java is no exception. Using one-dimensional sets of datavalues does not preclude using a two-dimensional array structure to access the data. The routines create2dArrayStructure(...)and destroy2dArrayStructure(...) in tempCalcRoutines.cpp demonstrate how onecan create a two-dimensional array structure which access the data allocated as a one dimensional array.

Java To C++ Conversion

This program is typical of many computationally intensive applications; data is allocated, parameters and valuesare initialized, and then a time stepping loop is executed. As the calculation proceeds data is output periodically.

The Fortran version of this program is given in tempCalc.f and the supporting routinesare given in tempCalcRoutines.f. One may notice that the C++ program is nearlyidentical to the Fortran program and does not use any of the object oriented features of C++ (i.e. it does notutilize classes). This was done intentionally so that the code would serve as an example of codes which are likelyto be used (and/or written) by the majority of those involved in scientific/technical computation.

The Java class that encapsulates the C, C++ or Fortrancodes components.

The second step in the process of creating an interface is to create a Java wrapper class that encapsulatesthe C, C++ or Fortran code components. It is in this class that the connection between the external routines andthe corresponding Java routines is made. This class is also responsible for 'loading' the external routines.

Essentially, this class replaces the main() routine. In this regard the class allocates the required arrays,contains the parameters as data members and also contains the methods (declared native) which are invoked by themain() driver routine (the initializeTemperature and evolveTemperature routines).

To facilitate the execution of the program as a separate thread, this class implements the Runnable interface(it implements a run() method). In this run() method, we have changed the output process to be one which displaysa color contour plot of the data, rather than write the output to a file. The requisite Java classes are containedin the files ColorContourPlot.java, ColorContourCanvas.javaand ContourResolutionDialog.java.

Lastly this routine also includes a main routine of it's own for testing purposes. The complete code is givenin TempCalcJava.java.

Since this routine has nativemethods, one must create the dynamically linked library (DLL) or sharedlibrary that contains their implementations. As outlined in the discussions on implementing native methods [1][7],this is a multi-step process:

  1. The class TempCalcJava.java is compiled. Even though the native methods are not implemented, you must compile the Java class containing the native methods before performing the next step.
  2. The command javah is applied to TempCalcJava.class. This means executing 'javah -jni TempCalcJava'. The result of this command is the creation of the file TempCalcJava.h. Since we are using the native interface specification of Java 1.1, the javah command must be the one distributed with the JDK 1.1.
  3. The functions contained in TempCalcJava.h are 'implemented'. In this regard our task consists of accessing the data contained within the Java arrays and passing it to the corresponding C++ (or Fortran routines). The implementation of these routines is given in TempCalcJava.cpp. (Note that one can select the Fortran implementation by defining __FORTRAN_BUILD__ in the compilation process.)
  4. The routines in TempCalcJava.cpp along with those in tempCalcRoutines.cpp are compiled and a dynamically linked library (or a shared library) is created. The name of this library must coincide with the name of the file (without the .dll or .so extension) which occurs in System.load or System.loadLibrary command within the static initializer for the class. (For some notes on the compilation process see Native Method Compilation Notes.)

See 'Native Method Implementation Process' for a diagram of thesesteps.

At this point, if the native method implementation process is successful, one should be able to run a 'commandline' version of the program by executing the main routine of the class i.e. just execute 'java TempCalcJava'.Problems which occur at this point are often caused by incorrect, or non-specification, of the path which is searchedfor the library containing the native method implementation. On PC/Windows platforms the PATH variable must includethe directory containing the native method implementation dll. On UNIX machines running solaris the LD_LIBRARY_PATHvariable must include the directory containing the native method implementation shared library.

The Java Interface

The third step in writing the interface is to write the Java class that implements the interface. Minimallythis means creating a Java application that possesses program control buttons and fields for data input. The interfaceis displayed below, and the associated Java code is contained within TemperatureApp.java.

Converter

Java To C Language Converter Download

This user interface was constructed using tools that generate Java 1.0.2. However, since our implementationof native methods is Java 1.1 based, after the initial construction, we compiled and worked with this code usingthe Java 1.1 compiler. In the Java 1.1 compilation step one must specify the flag '-deprication' andput up with all the warnings that are generated. Hopefully the interface construction tools will support Java 1.1soon and these nuisances will disappear.

In looking over the Java code, one should take note that the computationally intensive part of the applicationis done as a separate thread [6]. Specifically, within the code which gets executed whenthe Run button is hit (the code fragment is given below) we create threads for the separate components of the application---one thread for the calculation component and one thread for the color contour plot. The calculation component threadis given a lower priority, so that on machines whose implementation of the Java virtual machine doesn't time-sliceamong equal priority threads, the computationally intensive component will not cause the user interface to 'freeze'.

Java To C++ Translation

The color contour plot that results from the execution of the program is given below

References

  1. Campione, M. and Walrath, K., 'The Java Tutorial: Object-Oriented Programming for the Internet', Addison-Wesley, 1996.
  2. Cornell, G. and Horstmann, C., 'Core Java', SunSoft Press, 1996.
  3. Daconta, C., 'Java for C/C++ Programmers', Wiley Computer Publishing, 1996.
  4. Flanagan, D. 'Java in a Nutshell', O'Reilly and Associates, 1996.
  5. Jackson, J. and McClellan, A., 'Java by Example', SunSoft Press 1996.
  6. Oaks, S. and Wong, H., 'Java Threads', O'Reilly and Associates, 1997.
  7. Campione, M. and Walrath, K, Integrating Native Code and Java Programs