Mapping using Java Coding

I've got a big trouble. First, I'm trying to do mapping using Java Coding based on the TopLink Developer's Guide.
I'm using a Employee's Table as usual, but here is the problem, I can not do inserting on the database after I do mapping. As a note, there is no error compile and also I can do the session login already.
Employee.java
public class Employee extends oracle.toplink.sessions.Project{
     private Long id;
     private String fnama;
     private String lnama;
public Employee() {
setName("ObjectTab");
applyLogin();
addDescriptor(empDesc());
conformAllDescriptors();
public String getFnama() {
     return this.fnama;
public String getLnama() {
     return this.lnama;
public void setFnama(String fnama) {
     this.fnama = fnama;
public void setLnama(String lnama) {
     this.lnama = lnama;
public void applyLogin() {
DatabaseLogin login = new DatabaseLogin();
// use platform appropriate for underlying database
login.usePlatform(
new oracle.toplink.platform.database.oracle.Oracle9Platform());
login.setDriverClassName("oracle.jdbc.OracleDriver");
login.setConnectionString("jdbc:oracle:thin:localhost:1521:pusat");
login.setUserName("tryo");
login.setEncryptedPassword("a, ENCRYPTED");
// Configuration Properties
setDatasourceLogin(login);
public ClassDescriptor empDesc() {
ObjectRelationalDescriptor descriptor = new ObjectRelationalDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setTableName("EMPLOYEES");
descriptor.setStructureName("EMPLOYEE_T");
descriptor.setPrimaryKeyFieldName("ID");
descriptor.addFieldOrdering("ID");
descriptor.addFieldOrdering("F_NAME");
descriptor.addFieldOrdering("L_NAME");
descriptor.addDirectMapping("id", "OBJECT_ID");
descriptor.addDirectMapping("fnama", "F_NAME");
descriptor.addDirectMapping("lnama", "L_NAME");
return descriptor;
Main Class:
protected String getSessionsXmlPath() {
return "sessions.xml";
protected String getSessionName() {
return "Session";
protected void createSession() {
XMLSessionConfigLoader loader = new XMLSessionConfigLoader(getSessionsXmlPath());
SessionManager mgr = SessionManager.getManager();
session = (DatabaseSession)mgr.getSession(loader, getSessionName(), Thread.currentThread().getContextClassLoader(), true, true);
public static void closeSession(){
SessionManager.getManager().destroyAllSessions();
session = null;
private void jButton1_actionPerformed(ActionEvent e) {
Employee myEmp = new Employee();
createSession();
private void jButton2_actionPerformed(ActionEvent e) {
Employee theEmp = new Employee();
UnitOfWork uow = session.acquireUnitOfWork();
try{
theEmp.setFnama("A");
theEmp.setLnama("B");
uow.commit();
}finally{
uow.release();
For everybody who already knows the solution, please reply as soon as possible. Because I really need this solution to finish my last final project.
Thanks

When you create a new instance you must register it with the UnitOfWork in order to have the new entity persisted.
Employee theEmp = new Employee();
UnitOfWork uow = session.acquireUnitOfWork();
theEmp.setFnama("A");
theEmp.setLnama("B");
uow.registerObject(theEmp);
uow.commit();
Doug

Similar Messages

  • How to activate a specific profile of the Firefox using java coding?

    Hi Folks,
    I have some query regarding activating the Profiles of the Firefox. Whenever i open the Firefox, the profile manager will be prompting for the profile to be activated. I want to perform such similar operation through java coding. Let us assume, I have three profiles named default, office and personal. I need to invoke the Firefox with a specific profile, office. How to proceed further? Your suggestion will be highly appreciated...
    Thanks in Advance,
    RealStuff, Mike

    String s = "Less than 20";
    while(s.length() < 20) {
         s += " ";
    System.out.println(s + " " + s.length());Mark

  • Without BPM:Call RFC using JCO in interface mapping using java mapping

    Hi all
    I have a very small scenario where REQUEST from the customer comes via Web Service all i have to do is to read the request using SOAP adapter and call an interface mapping(lets say the name is IM_TEST) inside which there is a JAVA MAPPING program written which will call an RFC in CRM using JCO.
    Now this was really simple and i cud test the Interface mapping successfully, but the problem is when loading the scenario in integration directory i have certain things to do
    1. to set the SENDER AGREEMENT which i did correctly
    2. set the RECEIVER DETERMINATION, INTERFACE DETERMINATION AND RECEIVER AGREEMENT now here i am stuck because there is no receiver in my case as the RFC is called inside the mapping only.
    can i call one more message mapping in IM_TEST which will write file onto the XI directory and then in RECEIVER DETERMINATION, INTERFACE DETERMINATION AND RECEIVER AGREEMENT i can mention the reciever as FTP.
    I tried it but i gives the following error
    Runtime exception occurred during execution of application mapping program com/sap/xi/tf/_MM_TEST_WRITE_FILE: com.sap.aii.utilxi.misc.api.BaseRuntimeException; Parsing an empty source. Root element expected!
    Please help me how to complete the scenario so that customer can run it end to end.
    <REMOVED BY MODERATOR>
    Edited by: Prateek Raj Srivastava on May 12, 2010 1:44 PM

    Stefen
    What do i do then...actually this is the project requirement. They want a very fast response from PI and thats why they wnt us to omit BPM and the Graphical mapping from the scenario.
    I am able to test the interface mapping which calls the the Java mapping inside which there is an RFC call, but i cannot implement it end - to - end as there is no receiver business system in this case. The only business system i have is the SOAP sender.
    I am really troubled now, please help me with a solution.
    Is there any other possible way through which the process can become very fast whic hcan meet their requirement.
    Regards
    Naina

  • Multi Mapping using JAVA Mapping 1:n Transformation--Urgent??

    Hi,
    I have to make a 1:n Mapping with the JAVA Mapping. The situation is as follows:
    I have 1 ORDER with n positions and I have to convert this order to n ORDERS with 1 position in each order. My problem is, that I have to use the header-data of the input-order for each of the output orders and I have to use the first position of the input-order for the frist output-order the second postition for the second order and so on. Which mapping-steps do I have to use. I think this is an ordnary problem, but I could not find anything in the XI-help about this. Maybe anyon has got an idea.
    Regards,
    Raj

    hi
    The output from java mapping must look like
    <Messages>
    <Message1>
    <Your Traget Order>....
    </Message1>
    <Your Traget Order>....
    </Message1>
    </Messages>
    Create a Graphical mapping sample (1:N) to get an idea about this structure.
    refer this also
    /people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible
    rgds,
    Arun

  • Locating peaks and valleys on a map using java.

    This is the assignment for my excerice,if someone knows the code,please give it to me.
    I'm still beginner in java,and i have to submit that project by monday.
    Topographical maps are easily represented with two-dimensional
    arrays of integer or real valued
    heights. However, the bird's eye view they provide is sometimes
    difficult to appreciate after a day of
    lugging a 70-pound backpack.
    Consider a two-dimensional array variable storing real numbers and
    representing heights of a
    topographical map.
    Write a program that locates peaks. We define a peak as any point that
    is higher than its eight
    neighbors.
    Write a program that locates valleys. A valley is any series of three
    points along a row or column that
    are lower than their twelve neighbors. (Can you deal with longer
    valleys as well?)
    1. Define a two-dimensional array type for holding real numbers and
    having a size of maxrow times
    maxcol;
    2. Declare a Boolean method that tests if a point of this map
    represents a peak;
    3. From the main program locate all peaks and output their positions
    and heights;
    The header should be like this:
    peak number Row position Column position weight
    and for valleys it will the same heading
    valley number Row position Column position

    This is the assignment for my excerice,if someone
    knows the code,please give it to me.
    I'm still beginner in java,and i have to submit that
    project by monday.Tthis really isn't a beginners problem. Or if it's a beginners problem it's a beginners problem at a school with high standards. Above all it's clever. The problem is formulated in a way that you're unlikely to find code on the internet that exactly fits the bill and can be directly copied.
    So if you stay off the booze tonight and skip church tomorrow you have a whole day on your hands. Use it well. The problem is clearly formulated and should pose no problem for a rasonably smart student -:)

  • XML Structure Conversion using JAVA Mapping

    Hi Experts,
    I am having a requirement in which i want to convert the contents of source xml structure into a string and map it to the target field.
    Source Structure:
    <SRC>
    <Node1>ABCD</Node>
    <Node2>XYZ</Node2>
    <Node3>1234</Node>
    </SRC>
    Target Structure:
    <TRG>
    <Node1>ABCDXYZ</Node1>
    </TRG>
    Both the source and target structures are in xml format only.....just the condition is that I have to use Java mapping to achieve it.
    The contents of Source node Node3 are not to be mapped.
    Since I have very less knowledge of Java it will be very helpful if you provide the complete code to me.
    Thanks,
    Abhishek.

    Hello Udo,
    Thank you for reply. It seems ABAP mapping is easier.
    What do you think about the idea of using Value Mapping for such conversion task? In this case is it obligatory to use Java coding? And how about performance - will it be better than in case of ABAP mapping, can you say?
    Thank you,
    Igor

  • XSLT Mapping : RFC Lookup using java helper class

    Hi All,
    I am doing RFC Lookup in xslt mapping using java helper class. I have found blog for the same (http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14) However this blog is very advanced.
    Can anybody help me with step by step approach for the same?
    My basic questions are not answered in the blog as:
    1) where to add the jar file of the java class used in xslt mapping.
    I have added zip file of XSLT mapping in imported archived and using that in mapping.
    Thanks in advace.
    Regards,
    Rohan

    Hi,
    Can u please have look at this in detail , u can easily point out yourself the problem...
    http://help.sap.com/saphelp_nw04/helpdata/en/55/7ef3003fc411d6b1f700508b5d5211/content.htm
    Please observe the line,
    xmlns:javamap="java:com.company.group.MappingClass
    in XSLT mapping..
    The packagename of class and class name and XSLT namespace should be matching...
    Babu
    Edited by: hlbabu123 on Sep 29, 2010 6:04 PM

  • N:1 Mapping Possible using Java Mapping?

    All,
    Is it possible to do a N:1 mapping using Java Mapping?
    If yes , how?
    Reason for this question is that the execute() of the Java Mapping is going to take the source / request message as the InputStream . In the case of N:1 mapping , as we have multiple messages , how will they be send to the InputStream? Will both the messages be sent combined into the InputStream? Will the MESSAGES tag be embedded into the input stream?
    Regards,
    Bhavesh

    Hi @ll;
    i try the same.
    to conduct a java mapping with 2 input structures that fills one target structure.
    This mapping is part of a Integrationprocess.
    I tested the mapping at the Integration Repository (Interface mapping) with the structure given by henrique and it works fine without any error.
    At runtime this structure looks like this (different prefix)
    <?xml version="1.0" encoding="UTF-8"?>
    <sxi:Messages xmlns:sxi="http://sap.com/xi/XI/SplitAndMerge">
         <sxi:Message1>
              <YOURXML1>...</YOURXML1>
         </sxi:Message1>
         <sxi:Message2>
              <YOURXML2>...</YOURXML2>
         </sxi:Message2>
    </sxi:Messages>
    As I put it in the Integrationprocess unfortunately a strange error arises.
    The trace Workflow-Protocoll shows following error.
    <Trace level="2" type="T">Call method execute of the application Java mapping com.endress.infoserve.xi.mapping.MergeConfigStore_IdocOrder </Trace>
    <Trace level="2" type="T">Java mapping com/endress/infoserve/xi/mapping/MergeConfigStore_IdocOrder completed. (executeStep() of com.endress.infoserve.xi.mapping.MergeConfigStore_IdocOrder </Trace>
    <Trace level="1" type="T">Parsing error after multi mapping.Expected Message<i> instead of IDOC </Trace>
    I can't make head nor tail of it.
    what´s the mistake?
    can anybody please help me?
    Thanks in advance
    Kind regards

  • Retriving all records in the value mapping cache using java

    Hi,
    Is there a way to retrieve all records assuming I properly maintain some values in the value mapping using java? I know and I tried retrieving already using XIVMService.executeMapping but it seems that I can retrieve only 1 value at a time.
    For instance, in the value mapping cache I have the following:
    Agency         Schema         Value                Context
    SENDER       KEY              0001&ABC        http://xyz.com/ECC/ZTABLE
    SENDER       KEY              0003&           http://xyz.com/ECC/ZTABLE
    SENDER       KEY              0004&DEF        http://xyz.com/ECC/ZTABLE
    RECEIVER     RESULT           Hello           http://xyz.com/ECC/ZTABLE
    RECEIVER     RESULT           World           http://xyz.com/ECC/ZTABLE
    RECEIVER     RESULT           Hi              http://xyz.com/ECC/ZTABLE
    Is it possible to retrieve all values under the column Values assuming I know the value Agency, Schema and Context columns using a java program? If yes, can you point where I can find such an example code or if you are pointing to http://help.sap.com/javadocs/NW04S/current/pi/index.html please provide a sample code on how this can be done.
    Many thanks.

    Hi,
    Have you seen this weblogs by Prasad recently:
    /people/prasad.illapani/blog/2007/03/08/performance-tuning-checks-in-sap-exchange-infrastructure
    /people/prasad.illapani/blog/2007/04/20/performance-tuning-checks-in-sap-exchange-infrastructurexi-part-ii
    Also are you doing multiple lookups or a single lookup? If you are using multiple lookup for multiple fields which has the same logic then try to use global variables.
    ---Satish

  • Creating a New Folder in Windows Registry by java coding

    Good morning,
    hi to all,
    how can I create a New folder in Window Registry using Java coding. Can anybody help me out pls.
    I begin waiting for ur reply.
    Thanx

    Why do you feel you need to write to the Windows registry directly? Take a look at the Preferences class.
    {color:#0000ff}http://java.sun.com/javase/6/docs/api/java/util/prefs/Preferences.html{color}
    luck, db

  • Java Error in RFC Lookup in XSLT Mapping usinf Java helper class

    Hi All,
    I am doing RFC Lookup in XSLT Mapping using Java Helper class.
    The Lookup works fine when called one RFC at a time However my requirement is I want to do 2 Lookups.
    Both Lookups works when done individually however when I call both lookups in one mapping I get following error "javax.xml.transform.TransformerException: DOMSource whose Node is null."
    Following is the code I have written in XSLT for the lookup:
         <xsl:template name="Lookup_1">
              <xsl:param name="STDPN"/>
                   <rfc:RFC_READ_TABLE>
                        <QUERY_TABLE>KNA1</QUERY_TABLE>
                        <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$STDPN"/>
                             </TEXT></item>
                        </OPTIONS>
                        <FIELDS>
                             <item>
                                  <FIELDNAME>KUNNR</FIELDNAME>
                             </item>
                        </FIELDS>
                   </rfc:RFC_READ_TABLE>
              </xsl:variable>
              <xsl:variable name="response" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request, 'BS_D, 'cc_RfcLookup', $inputparam)"/>
              <xsl:element name="STDPN">
                   <xsl:value-of select="$response//DATA/item/WA"/>
              </xsl:element>
         </xsl:template>
         <xsl:template name="Lookup_2">
              <xsl:param name="BELNR"/>
                   <xsl:variable name="Query">AGMNT = '<xsl:value-of select="$BELNR"/>'</xsl:variable>
                   <xsl:variable name="request1">
                        <rfc:RFC_READ_TABLE>
                             <QUERY_TABLE>ZTABLE</QUERY_TABLE>
                             <OPTIONS><item><TEXT>
                                  <xsl:value-of select="$Query"/>
                                  </TEXT></item>
                             </OPTIONS>
                             <FIELDS>
                                  <item>
                                       <FIELDNAME>KUNAG</FIELDNAME>
                                  </item>
                             </FIELDS>
                        </rfc:RFC_READ_TABLE>
                   </xsl:variable>
                   <xsl:variable name="response1" xmlns:lookup="java:urn.mt.pi" select="lookup:execute($request1, 'BS_D','cc_RfcLookup', $inputparam)"/>
                   <xsl:element name="BELNR">
                        <xsl:value-of select="$response1//DATA/item/WA"/>
                   </xsl:element>
         </xsl:template>
    My Question: Am I doing anything wrong? Or Is it possible to call multiple lookups in one XSLT?
    Thanks and Regards,
    Atul

    Hi Atul,
    I had the same problem like you had.
    The main Problem is that with the example code the request variable is created as NodeList object. In XSLT a variable is somekind of a constant and can't be changed. As the request object is empty after the first request the programm fails at the following line:
    Source source = new DOMSource(request.item(0));
    So I've created a workaround for this problem.
    In the call of the template I've put the request as a parameter object at the template call:
    <xsl:with-param name="req">
    <rfc:PLM_EXPLORE_BILL_OF_MATERIAL xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
      <APPLICATION>Z001</APPLICATION>
      <FLAG_NEW_EXPLOSION>X</FLAG_NEW_EXPLOSION>
      <MATERIALNUMBER><xsl:value-of select="value"/></MATERIALNUMBER>
      <PLANT>FSD0</PLANT>
      <VALIDFROM><xsl:value-of select="//Recordset/Row[name='DTM-031']/value"/></VALIDFROM>
      <BOMITEM_DATA/>
    </rfc:PLM_EXPLORE_BILL_OF_MATERIAL>
    </xsl:with-param>
    With this change the request will be provided as a String object and not as a NodeList object.
    Afterwards the RfcLookup.java has to be changed to the following:
    package com.franke.mappings;
    import java.io.ByteArrayInputStream;
    import java.io.ByteArrayOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintWriter;
    import java.io.StringWriter;
    import java.util.Map;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMSource;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import com.sap.aii.mapping.lookup.Channel;
    import com.sap.aii.mapping.api.StreamTransformationConstants;
    import com.sap.aii.mapping.api.AbstractTrace;
    import com.sap.aii.mapping.lookup.RfcAccessor;
    import com.sap.aii.mapping.lookup.LookupService;
    import com.sap.aii.mapping.lookup.XmlPayload;
    * @author Thorsten Nordholm Søbirk, AppliCon A/S
    * Helper class for using the XI Lookup API with XSLT mappings for calling RFCs.
    * The class is generic in that it can be used to call any remote-enabled
    * function module in R/3. Generation of the XML request document and parsing of
    * the XML response is left to the stylesheet, where this can be done in a very
    * natural manner.
    * TD:
    * Changed the class that request is sent as String, because of IndexOutOfBound-exception
    * When sending multiple requests in one XSLT mapping.
    public class RfcLookup {
         * Execute RFC lookup.
         * @param request RFC request - TD: changed to String
         * @param service name of service
         * @param channelName name of communication channel
         * @param inputParam mapping parameters
         * @return Node containing RFC response
         public static Node execute( String request,
                 String service,
                 String channelName,
                 Map inputParam)
              AbstractTrace trace = (AbstractTrace) inputParam.get(StreamTransformationConstants.MAPPING_TRACE);
              Node responseNode = null;
              try {
                  // Get channel and accessor
                  Channel channel = LookupService.getChannel(service, channelName);
                  RfcAccessor accessor = LookupService.getRfcAccessor(channel);
                   // Serialise request NodeList - TD: Not needed anymore as request is String
                   /*TransformerFactory factory = TransformerFactory.newInstance();
                   Transformer transformer = factory.newTransformer();
                   Source source = new DOMSource(request.item(0));
                   ByteArrayOutputStream baos = new ByteArrayOutputStream();
                   StreamResult streamResult = new StreamResult(baos);
                   transformer.transform(source, streamResult);*/
                    // TD: Add xml header and remove linefeeds for the request string
                    request = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+request.replaceAll("[\r\n]+", ""); 
                    // TD: Get byte Array from request String to send afterwards
                    byte[] requestBytes = request.getBytes();
                   // TD: Not used anymore as request is String
                    //byte[] requestBytes = baos.toByteArray();
                    trace.addDebugMessage("RFC Request: " + new String(requestBytes));
                    // Create input stream representing the function module request message
                    InputStream inputStream = new ByteArrayInputStream(requestBytes);
                    // Create XmlPayload
                    XmlPayload requestPayload =LookupService.getXmlPayload(inputStream);
                    // Execute lookup
                    XmlPayload responsePayload = accessor.call(requestPayload);
                    InputStream responseStream = responsePayload.getContent();
                    TeeInputStream tee = new TeeInputStream(responseStream);
                    // Create DOM tree for response
                    DocumentBuilder docBuilder =DocumentBuilderFactory.newInstance().newDocumentBuilder();
                    Document document = docBuilder.parse(tee);
                    trace.addDebugMessage("RFC Response: " + tee.getStringContent());
                    responseNode = document.getFirstChild();
              } catch (Throwable t) {
                   StringWriter sw = new StringWriter();
                   t.printStackTrace(new PrintWriter(sw));
                   trace.addWarning(sw.toString());
              return responseNode;
         * Helper class which collects stream input while reading.
         static class TeeInputStream extends InputStream {
               private ByteArrayOutputStream baos;
               private InputStream wrappedInputStream;
               TeeInputStream(InputStream inputStream) {
                    baos = new ByteArrayOutputStream();
                    wrappedInputStream = inputStream;
               * @return stream content as String
               String getStringContent() {
                    return baos.toString();
              /* (non-Javadoc)
              * @see java.io.InputStream#read()
              public int read() throws IOException {
                   int r = wrappedInputStream.read();
                   baos.write(r);
                   return r;
    Then you need to compile and upload this class and it should work.
    I hope that this helps you.
    Best regards
    Till

  • How to pass input parameter (parameterized mapping) to java mapping program

    Hello
    I have a question about the parameterized mapping with Java (PI 7.1).
    In the operation mapping (using Java-class) I defined a inputer parameter (string). I think I am supposed to retrieved the value using:
                    arg0.getInputParameters().getString("myInputParameterName");
    where arg0 is the TransformationInput object.
    However I am not able to get the value, I got runtime exception saying the inputer parameter doesn't exit.
    Then I figured out maybe I need to bind the OM input parameter to Java mapping parameter, just like in case of message mapping, you need to bind OM parameter to MM parameter. However there is no way to define input parameter for the java mapping program.
    Anybody has done java mapping with parameterized mapping?
    Anybody can give any hint for this?
    Thanks
    Jayson

    InputParameters params = container.getInputParameters();
    DynamicConfiguration conf = (DynamicConfiguration) params.getValue(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File", "Directory");
    http://help.sap.com/saphelp_nwpi71/helpdata/en/43/03612cdecc6e76e10000000a422035/content.htm
    Edited by: Anand on Dec 10, 2008 4:13 PM

  • Error about Source Level only if 5.0?  I'm using Java 1.6?  Maps

    Hello everyone. I was just trying to run some simple Source Code from my book here:
    package mapa;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Set;
    public class MapTest
         Map<String, String> phonebook = new HashMap<String, String>();
        // constructor
        public example2(String n[], String nums[]) {
           for(int i=0; i< n.length; i++)
               phonebook.put( n, nums[i] );
    public static void main(String[] args) {
    // data
    String [] names = { "Lefty", "Guarav", "Wong", "Rupamay" };
    String [] extns = { "4873", "4810", "3769", "0" };
    // get an instance of this class
    example2 ex = new example2( names, extns );
    // dump out the map
    System.out.println("map: " + ex.phonebook);
    // get the mappings
    Set<Map.Entry<String,String>> s = ex.phonebook.entrySet();
    // iterate over the mappings
    // for (Iterator i = s.iterator(); i.hasNext(); ) {
    for (Map.Entry me : s) {
    Object ok = me.getKey();
    Object ov = me.getValue();
    System.out.print("key=" + ok );
    System.out.println(", value=" + ov );
    and i'm getting the following errors when I run it in Eclipse:
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         example2 cannot be resolved to a type
         example2 cannot be resolved to a type
         Syntax error, parameterized types are only available if source level is 5.0
         The type Map.Entry is not generic; it cannot be parameterized with arguments <String, String>
         Syntax error, 'for each' statements are only available if source level is 5.0
         at mapa.MapTest.main(MapTest.java:24)Line 24 is:
      example2 ex = new example2( names, extns );I've compiled things with Eclipse before such as Networking programs and they worked fine, not sure whats wrong with this example.
    Thanks!

    Oops it looks like on that line they are using the Class itself, and they had it renamed to Example2 not MapTest. I changed the code to the following but still getting errros:
    package mapa;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Set;
    public class MapTest
         Map<String, String> phonebook = new HashMap<String, String>();
        // constructor
        public example2(String n[], String nums[]) {
           for(int i=0; i< n.length; i++)
               phonebook.put( n, nums[i] );
    public static void main(String[] args) {
    // data
    String [] names = { "Lefty", "Guarav", "Wong", "Rupamay" };
    String [] extns = { "4873", "4810", "3769", "0" };
    // get an instance of this class
    MapTest ex = new MapTest( names, extns );
    // dump out the map
    System.out.println("map: " + ex.phonebook);
    // get the mappings
    Set<Map.Entry<String,String>> s = ex.phonebook.entrySet();
    // iterate over the mappings
    // for (Iterator i = s.iterator(); i.hasNext(); ) {
    for (Map.Entry me : s) {
    Object ok = me.getKey();
    Object ov = me.getValue();
    System.out.print("key=" + ok );
    System.out.println(", value=" + ov );
    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
         The constructor MapTest(String[], String[]) is undefined
         ex.phonebook cannot be resolved or is not a field
         Syntax error, parameterized types are only available if source level is 5.0
         The type Map.Entry is not generic; it cannot be parameterized with arguments <String, String>
         ex.phonebook cannot be resolved or is not a field
         Syntax error, 'for each' statements are only available if source level is 5.0
         at mapa.MapTest.main(MapTest.java:24)

  • Splitting using Java mapping

    Hi,
        I am working on a file to IDOC scenario.In the input file am getting data for multiple idocs.The file structure is such that in the sender communication channel am not able to identify the recordsets and hence cannot set the number of recordsets per message parameter,else would have generated multiple messages there itself.
       I want to implement java mapping.
       Can any one please tell me is splitting possible in java mapping, such that once the data for one idoc is over I will generate another idoc.
    Thnx,
    Pravesh Puria.

    Hi Puria,
    have a look to <a href="/people/jin.shin/blog/2006/02/07/multi-mapping-without-bpm--yes-it146s-possible without BPM - Yes, it’s possible!</a>. Instead of the message mapping use your java mapping. You have to build your result XML like:
    <Messages xmlns:ns="myNamespace">
    <Message1>
    </MyFirstMessage>
    </Message1>
    <Message2> and so on
    Regards,
    Udo

  • How to display Map for viewing in browser using Java

    I am fidning a solution for displaying political maps in browser using Java technology.
    Is ther anybody with a solution.
    Waiting for your respone.
    Regards
    Mithun

    palanithendral wrote:
    Hi,
    Our application using in English, German, Franch and chinese.You have several different idioms in your application and have not accurately identified where the actual problem is. You have all of the following
    -database
    -http
    -excel
    -excel in http
    -display on the target computer
    The first step with these sorts of problem is to identify where the problem actually occurs.
    String chineseCharacter=""; // chineseCharacter like &#38263;&#38271;&#29248;&#24202;&#26481;&#19996;&#24447;&#20315;. This chinese data coming from oracle database..A good theory. Now explain how you proved that that is what is coming from the database.
    After export the data to excel show the result for 長长牀床東东彿佛.As another example. Presumably you are referring to what the browser on the target computer displays. Your theory is that that computer and that browser (together) will display the correct information if they had the correct data. How did you prove that?

Maybe you are looking for

  • Purchase Order using ESOA

    Hi, I am working on ERP 6 (Ehp 4) and SUS. Could someone pl provide me the settings to be made in ERP for sending out PO's to SUS using ESOA. Pl throw some light on t-code SOAMANAGER and the settings to be made to enable sending out PO from ECC to SU

  • A thin blue line has appeared on my ipod

    I have a new ipod touch 1 month old and a thin blue line has appeared on screen right down the middle.  how do I get rid of this?

  • UTF8 Conversion error

    The thin driver sometimes gives this error: Fail to convert between UTF8 and UCS2 when accessing Oracle 8i set to UTF8 charset. Is this a known bug? Does anyone know a workaround?

  • How can I transfer/import iPhotos from iMac to MacBook Pro?

    How can I transfer some  photos from iPhoto on iMac Desktop to iPhoto on MacBook Pro?

  • XI Production !

    Hi , Greetings ! Here is our Scenario --> --> XI --> We are going with above scenario for one our client for transactional Data transfer , Transactional data is so frequent and has to be captured very frequently. Our Data transfer are bi-directional