Problem with java.util while migrating an app. from Apache to OC4J

Hello.
I have a application which runs fine under APache/Jserv . This
application contains bunch of jsp's. In the jsp's even though
there are no directives for import of java.util.* packages it
still works fine. But under oc4j the same application does not
work unless I modify the jsp to include java.util.* in the
import directive. What am I missing here?.
Thanks in advance.
Prakash

Hi,
I think that Apache/Jserv does the inlcude of java.util.*
automatically which OC4J dosen't.
Thanks,
Andy
Hello.
I have a application which runs fine under APache/Jserv . This
application contains bunch of jsp's. In the jsp's even though
there are no directives for import of java.util.* packages it
still works fine. But under oc4j the same application does not
work unless I modify the jsp to include java.util.* in the
import directive. What am I missing here?.
Thanks in advance.
Prakash

Similar Messages

  • Problems with Java AQ interface migrating 9i to 10g

    Hi!
    I've got problems with Java AQ Interface migrating from 9i DB, JDBC, AQ to 10g rel.2 DB, JDBC, AQ
    First, i started to occasionally receive NullPointerException in Oracle JDBC 9.2.0.8
    java.lang.NullPointerException
    at oracle.jdbc.driver.OracleStatement.describe(OracleStatement.java:6439)
    at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java:6203)
    at oracle.jdbc.driver.OracleResultSetImpl.findColumn(OracleResultSetImpl.java:1557)
    at oracle.jdbc.driver.OracleResultSet.getString(OracleResultSet.java:1543)
    at gpnic.messaging.LDAPMessenger.messageFromRS(Unknown Source)
    We were using 9.2.0.8 JDBC and 9i and 10g databases.
    We decided to go up for 10g r2 JDBC Drivers, and 10.2 AQ but started to get the following errors:
    oracle.AQ.AQOracleSQLException: ORA-25216: invalid recipient, either NAME or ADDRESS must be specified
    ORA-06512: на "SYS.DBMS_AQIN", line 454
    ORA-06512: на line 1
         at oracle.AQ.AQOracleQueue.enqueue(AQOracleQueue.java:1267)
         at gpnic.comm.messaging.transport.AQTransportAdapter$AQDestanation.send(AQTransportAdapter.java:607)
         at gpnic.comm.messaging.transport.OutboundThread.run(OutboundThread.java:83)
    I'm specifying address of an agent, but oracle says I am not.
    I tried both native AQ and JMS interfaces, bot got the same error. I specify recipient the following way:
    'consumer' var contains name of AQ agent and is not null
    native AQ interface:
    aqSess = AQDriverManager.createAQSession(db_conn);
    AQQueue destQ = aqSess.getQueue(schema, queue);
    dequeueOptionsOut = new AQDequeueOption();
    dequeueOptionsOut.setWaitTime(AQDequeueOption.WAIT_NONE);
    dequeueOptionsOut.setConsumerName(consumer);
    dequeueOptionsOut.setDequeueMode(AQDequeueOption.DEQUEUE_REMOVE);
    dequeueOptionsOut.setNavigationMode(AQDequeueOption.NAVIGATION_FIRST_MESSAGE);
    AQMessageProperty mpOut = new AQMessageProperty();
    Vector vRecpt = new Vector();
    vRecpt.add(new AQAgent(consumer, null, 0));
    mpOut.setRecipientList(vRecpt);
    AQMessage aqMsg = null;
    AQEnqueueOption eOpt = null;
    //prepare message
    aqMsg = destQ.createMessage();
    CLOB chMsg = CLOB.createTemporary(db_conn, true, CLOB.DURATION_SESSION);
    chMsg.open(CLOB.MODE_READWRITE);
    chMsg.putString(1,msg);
    //creating oracle type message
    gpnic.db.SDSTypes.SdsMsgT oraMsg = new gpnic.db.SDSTypes.SdsMsgT(chMsg);
    AQObjectPayload payload = aqMsg.getObjectPayload();
    payload.setPayloadData(oraMsg);
    //setting properties
    aqMsg.setMessageProperty(mpOut);
    //do enqueueOut
    eOpt = new AQEnqueueOption();
    destQ.enqueue(eOpt, aqMsg); //<- here AQOracleSQLException is thrown
    JMS interface to Oracle AQ:
    TopicSession session;
    TopicConnection connection;
    TopicPublisher publisher;
    AQjmsAgent[] recipientList;
    connection = AQjmsTopicConnectionFactory.createTopicConnection(db_conn);
         session = connection.createTopicSession(true, Session.CLIENT_ACKNOWLEDGE);
         connection.start();
         Topic topic = ((AQjmsSession) session).getTopic(schema, queue);
         publisher = session.createPublisher(topic);
         recipientList = new AQjmsAgent[1];
         recipientList[0] = new AQjmsAgent(consumer, null);
    CLOB chMsg = CLOB.createTemporary(db_conn, true, CLOB.DURATION_SESSION);
    chMsg.open(CLOB.MODE_READWRITE);
    chMsg.putString(1,msg);
    //creating oracle type message
    gpnic.db.SDSTypes.SdsMsgT oraMsg = new gpnic.db.SDSTypes.SdsMsgT(chMsg);
    AdtMessage adtMessage = ((AQjmsSession)session).createAdtMessage();
    adtMessage.setAdtPayload(oraMsg);
    ((AQjmsTopicPublisher) publisher).publish(adtMessage, recipientList); <- here Exception is thrown
    We tried the following combinations
    9i DB, 9i jdbc, 9i aq - enqueue ok
    10g DB, 9i jdbc, 9i aq - enqueue ok
    10g DB, 10g jdbc, 10g aq - exception is thrown
    Can anyone help?

    Duplicate post, please check Upgrade 9i to 10g

  • Problems with java.util.zip

    I've got a odd problem here. I'm not sure if this is the appropriate forum but I couldn't find anyplace more appropriate.
    So the problem is...
    I create my ZIP file and if I open it in WinZip, no problem. But if I open the ZIP file using the 'Compressed Folders' feature of Windows Explorer I don't see any of the files. As far as I can tell, if the files I ZIP up do not contain any path information then they open fine via 'Compressed Folders'.
    Is this a bug in java.util.zip? Or is the 'Compressed Folders' feature in Windows Explorer half-baked?
    And finally is there any way for me to not include the path information of the files added to ZIP?
    Thanks.

    Looce:
    I'm more than willing to modify things.
    But I'm still curious why WinZip and Windows are treating the ZIP files differently.
    Also, the only way I can figure to get the files into the ZIP without the path information being stored in the ZIP file is by copying the files to the directory containing my application jar file and then passing in the file name without the path being specified. That is the only way FileInputStream would be able to find the files without including path information. This seems like a lot of unnecessary overhead.
    Another oddity is that if I create the ZIP archive using the file path for the FileInputStream and view the ZIP file using a HEX editor the entire path is being stored including the drive letter. But if you view the file using WinZip the path field seems to be removing the drive letter and only displaying the path. On top of that, even though the drive letter is contained in the archive if you unzip the file using WinZip it ignores the drive letter and unzips the file to whatever drive the archive is located on. In the grand scheme of things it makes sense for WinZip to ignore the drive letter.
    Thanks for you help anyways.

  • Problem with DECODE statement while migrating forms to 6i

    Hi,
    I'm migrating a form from 5 to 6i. When I compiled the form, I got this error witha decode statement.
    The error is
    Error 307 at line 15 column 7
    too many declarations of "DECODE" match this call
    The trigger has this code:
    IF :PRUN_RECS_INSERTED = 'Y' THEN
          RETURN ;
       END IF ;
       INSERT INTO GJBPRUN
        ( GJBPRUN_JOB,
          GJBPRUN_ONE_UP_NO,
          GJBPRUN_NUMBER,
          GJBPRUN_ACTIVITY_DATE,
          GJBPRUN_VALUE )
       SELECT :KEYBLCK_JOB,
              :ONE_UP_NO,
               GJBPDFT_NUMBER,
               SYSDATE,
          DECODE(GJBPDFT_VALUE, 'SYSDATE',
                          DECODE(GJBPDEF_LENGTH,'11',TO_CHAR(SYSDATE,'DD-MON-YYYY'), SYSDATE),
                          GJBPDFT_VALUE)
       FROM   GJBPDFT G, GJBPDEFEdited by: Charan on Mar 16, 2011 9:15 AM

    Hi Charan
    i think it's all about using both CHARACTER and DATE values at the same time in a DECODE statment u should either use char or date datatype.
    DECODE compares expr to each search value one by one. If expr is equal to a search, then Oracle Database returns the corresponding result. If no match is found, then Oracle returns default. If default is omitted, then Oracle returns null.
    e.g.
    If expr and search are character data, then Oracle compares them using nonpadded comparison semantics.
    expr, search, and result can be any of the datatypes CHAR, VARCHAR2, NCHAR, or NVARCHAR2.
    The string returned is of VARCHAR2 datatype and is in the same character set as the first result parameter.
    for more pls have a look here
    Hope this helps,
    Regards,
    Abdetu...

  • Problem With the Triggers while migrating Forms from 5 to 6i

    When I open the version 5 fmb file in Forms 6i, some of the triggers in the form level triggers and also in data block, are having red arrow marked on them and they seem to have no code in them. So when i compile the form then those triggers are shown as errors and when I close those triggers, they are deleting.
    The error looks like this..
    Error 103 at line 2, column 1
    Encountered the symbol "END" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod null pragma raise
    return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql commit <a single-quoted SQL string>
    And finally the form will compile with out any errors. But when I run the form getting error again saying,
    FRM 10221: Cannot read file

    Hi,
    the forms migration assistant tells you about v2 styles triggers (even if they are not migrated ; ) )
    take a look at :
    [url http://download.oracle.com/docs/cd/E15523_01/doc.1111/e10394/migtool.htm#i100490]Using the Oracle Forms Migration Assistant
    Raises a warning in the Form module's log if V2-style triggers are found.
    There is also a point you must look at.
    In a former project I made a migration from forms 4.5 to 10g and there was foms-level triggers applied at let say the block level or item level (I cant remember exactly) and this is not permitted anymore in 10g.
    Again the forms migration assistant Provides warnings about triggers defined at incorrect levels.
    Hope this helps
    Regards,
    Jean-Yves
    Edited by: JeanYves Bernier on Mar 10, 2011 9:10 PM

  • Type Mapping Problem with java.util.Vector in Axis

    Hi,buddies,I want to use the Vector class as the return type of my service, but it seems that there isn't a built-in Ser/Deser factory for Vector, is it?So i think we need to provide our own Ser/Derser. and this is a very common problem,and i wonder how to write my own Ser/Derser, please give me some suggestion,thx!
    Best Regards:)

    Hi,I checked out the src of Axis 1.2, I found there is a org.apache.axis.encoding.ser.VectorSerializerFactory class and an according org.apache.axis.encoding.ser.VectorDeserializerFactory class.so in the deploy.wsdd i use them as the ser/deser factories in the TypeMapping part inside the service tag.everything goes well and i got no problem deploying the service to axis.But the problem is that when i try to invoke the service and get a vector as return(Suppose the components in the vector is instances of Movie class), the following error occured:
    org.xml.sax.SAXException: No deserializer for {urn:movies}Movie
    But it is a little bit confusing,for I declared the ser/deser factories for the bean class Movie(with built-in ser/deser factories of axis),and everything was going fine when i deployed the service to axis.So should i still use the TypeMappingRegistry or there are something i just missed.Please give me some suggestion,thx :)
    Best Regards:)

  • Problem with java.util.logging - write to multiple log files

    Hi guys,
    I'm having trouble with logging to multiple files - i am using the constructor for creating multiple files with size limitation - FileHandler(String pattern, int limit, int count, boolean append).
    The problem i encounter is that it writes to the next log file before exceeding the limit, can it be because of file lock or something? what can i do in order to fill log files in a given limit and then write to the next?

    I thought it is synchronized by definition - i'm just creating loggers that write to
    the same file(s). When i used 1 file instead of using the limit and several
    files - all went well.Just a small question: all these loggers do use the same FileHandler don't they?
    I bet they do, just asking ...
    The problem started when i wanted each file to reach a limit before start writing
    to a new file. Should i synchronize the log somehow? That's what I suggested in my previous reply, but IMHO it shouldn't be necessary
    given what I read from the sources ...
    What could be the reason for not reaching the limit before opening a new file?Sorry I don't have an answer (yet), still thinking though ... it's a strange problem.
    kind regards,
    Jos (hrrmph ... stoopid problem ;-)

  • Problem with special charecter while calling a BAPI from Webdynpro JAVA.

    Hi Experts,
    I am calling a BAPI from Webdynpro JAVA. I am passing a special charecter  u2018 as input to BAPI. But I am getting a # as input in R/3.. Can any one explain why it is getting changed?
    Any inputs regarding this issue are appreciated.
    Thanks,
    Kasinath.

    Hi,
        I had same problem before..For this I have created function module in backend for removing #. It was for converting Stream to ITF text.
    CONVERT_STREAM_TO_ITF_TEXT.
    Try this.
    Thanks,
    Prajakta

  • Problem with OO4O opendatabase() call, migrating the client from 9i to 10g

    I have the following code:
    VARIANT* pvaparams = new VARIANT[3];
    if (pvaparams == NULL)
    return NULL;
    for (int nIndex = 0; nIndex < 3; nIndex++)
    VariantInit(&pvaparams[nIndex]);
    pvaparams[0].vt = VT_I4;
    pvaparams[0].lVal = ORADB_ORAMODE;
    pvaparams[1].vt = VT_BSTR;
    pvaparams[1].bstrVal = bstrConnect; //user and passwd
    pvaparams[2].vt = VT_BSTR;
    pvaparams[2].bstrVal = bstrDBname; //database name
    VARIANT va_out;
    VariantInit(&va_out);
    va_out.vt = VT_DISPATCH; // expect IDispatch* for database
    DISPPARAMS params = {pvaparams, NULL, 3, 0};
    EXCEPINFO eInfo;
    unsigned int uiArgErr;
    //dispid_OpenDatabase OK, previously obtained
    hRes = m_pIOracleSession->Invoke( dispid_OpenDatabase, IID_NULL,1033,
    DISPATCH_PROPERTYGET , &params , &va_out,
    &eInfo, &uiArgErr );
    if ( FAILED( hRes ) )
    throw new COracleDBXception(eInfo);
    This is from an application developped in VC++ 5 which uses COM and OO40 for connecting to a 9i database; and works fine, with a 9.2.0.1.0 client.
    I have updated the server to 10g and kept the client and it's running OK.
    After that, I have installed the 10.2.0.1.0 client and it's not working anymore; the odd thing is that the call to Invoke() has succeded and hRes is 0, but there is no connection to the database!!!
    I set a breakpoint after Invoke() and, from PL/SQL Developer, the "select OSUSER, PROGRAM, TERMINAL from v$session t where username='NORO';" command reports nothing; with the 9i client, it was reporting 1 connection.
    I would like to add that I had uninstalled completely the 9i client and after that I installed the 10g client.
    Can anyone give me a hint?
    Thank you!

    Hi everyone!
    static const CLSID CLSID_Oracle =
    {0x3893b4a0, 0xffd8, 0x101a, {0xad, 0xf2, 0x04, 0x02, 0x1c, 0x00, 0x70, 0x02}};
    const DWORD ORADB_ORAMODE = 0x1 ;
    STDMETHODIMP Test()
         HRESULT     hr;
         IDispatch* pIDefaultSession;
         hr = ::CoCreateInstance( CLSID_Oracle, NULL, CLSCTX_SERVER, IID_IDispatch, (void**)&pIDefaultSession );
         if (hr != S_OK)
              return S_FALSE;
         // CreateNamedSession - DISPID: 0x6001000B
         // OpenDatabase - DISPID: 0x60010001
         // create unique name
         TCHAR strName[256];
         stprintf( strName, T("Session#%d"), 1);
         // call 'CreateNamedSession' method
         VARIANT vaparam;
         VariantInit(&vaparam);
         vaparam.vt = VT_BSTR;
         vaparam.bstrVal = SysAllocTString(strName);
         VARIANT va_out_3nd;
         VariantInit(&va_out_3nd);
         va_out_3nd.vt = VT_DISPATCH;     // expect IDispatch* for named session
         DISPPARAMS params = {&vaparam, NULL, 1, 0};
         EXCEPINFO excepinfo;
         unsigned int uiArgErr;
         // Invoke CreateNamedSession
         hr = pIDefaultSession->Invoke( 0x6001000B, IID_NULL, 1033, DISPATCH_PROPERTYGET, &params, &va_out_3nd, &excepinfo, &uiArgErr );
         ::SysFreeString(vaparam.bstrVal);
         if ( FAILED(hr) )
              return S_FALSE;
         CComPtr<IDispatch> m_pIOracleSession;      // pointer to the session
         m_pIOracleSession.p = va_out_3nd.pdispVal;
         // call "OpenDatabase" method
         HRESULT hRes;
         CSString m_strDbId = _T("databasename");
         CSString m_strUserName = _T("username");
         CSString m_strPswd = _T("password");
         CComBSTR bstrDBName = SysAllocTString(m_strDbId);
         CComBSTR bstrConnect = SysAllocTString(m_strUserName + T("/") + mstrPswd);
         VARIANT* pvaparams = new VARIANT[3];
         if (pvaparams == NULL)
              return S_FALSE;
         for (int nIndex = 0; nIndex < 3; nIndex++)
              VariantInit(&pvaparams[nIndex]);
         pvaparams[0].vt = VT_I4;
         pvaparams[0].lVal = ORADB_ORAMODE;
         pvaparams[1].vt = VT_BSTR;
         pvaparams[1].bstrVal = bstrConnect;
         pvaparams[2].vt = VT_BSTR;
         pvaparams[2].bstrVal = bstrDBName;
         VARIANT va_out_2nd;
         VariantInit(&va_out_2nd);
         va_out_2nd.vt = VT_DISPATCH;      // expect IDispatch* for database
         DISPPARAMS params_2nd = {pvaparams, NULL, 3, 0};
         EXCEPINFO eInfo;
         unsigned int uiArgErr_2nd;
         // invoke OpenDatabase:
         //here is the problem!!!
         hRes = m_pIOracleSession->Invoke(0x60010001, IID_NULL, 1033, DISPATCH_PROPERTYGET , &params_2nd , &va_out_2nd, &eInfo, &uiArgErr_2nd );
         delete pvaparams;
         if ( FAILED( hRes ) )
              return S_FALSE;
         CComPtr<IDispatch> m_pDatabase;
         m_pDatabase.p = va_out_2nd.pdispVal;
         CreateCustomDynaset - DISPID: 0x6001000C
         ExecuteSQL - DISPID: 0x60010006
         LastServerErrText - DISPID: 0x60010009
         Parameters - DISPID: 0x00000000
         LastServerErrReset - DISPID: 0x6001000B
         TCHAR* pAlterNumeric = T("ALTER SESSION SET NLSNUMERIC_CHARACTERS = \".,\"");
         // call "ExecuteSQL" method
         VARIANT va_params;
         VariantInit(&va_params);
         va_params.vt = VT_BSTR;
         va_params.bstrVal = SysAllocTString(pAlterNumeric);
         DISPPARAMS params_3nd = {&va_params, NULL, 1, 0};
         unsigned int uiArgErr_3nd;
         // Invoke ExecuteSQL:
         hr = m_pDatabase->Invoke( 0x60010006, IID_NULL, 1033, DISPATCH_METHOD, &params_3nd, NULL, &eInfo, &uiArgErr_3nd );
         if (FAILED(hr))
              return S_FALSE;
         return S_OK;
    If this function is called from DllMain(), it works. But if we call this function from another method from our .dll, and that method is called via COM from a client, this function doesn't work anymore! We use VC++ 5 and the 10g Oracle client.
    Can anyone give me a explanation?
    PS: The call to opendatabase() is successfull, but we don't see a connection on the database server and we get a SEGV error: "function not mapped to object".
    Noro

  • Early problems with Java on my Macbook.

    Hi, I am a former high school computer science student and I'm having problems with Java as I've recently moved from Windows to a Mac. The following is a letter I wrote to my prior computer science teacher but he does not seem to be responding. I think all you need to know is that DrawHouse and JumpingJacks are simple Java programs we made in class that utilize an object called DrawingTool (which is a graphics environment). DrawingTool is contained in gpdraw.jar and also was contained in our class' apcslib.jar. Also, FileInput is a class contained in apcslib.jar.
    I basically transferred all my JAR files (apcslib.jar, etc.) from my Windows computer to my Mac. I didn't think anything was wrong or corrupted with them because they're the same JAR files that I used for my Java programs on my Windows comp in high school and when I run those Java programs now, they still work. But for some reason if I try to run, say, DrawHouse or JumpingJacks with those same programs on my Macbook, it gives me the following errors on runtime (it compiles fine).
    Exception in thread "main" java.lang.NullPointerException
         at apcslib.DrawingTool.move( DrawingTool.java:456)
         at java.awt.Component.setLocation( Component.java:1705)
         at java.awt.Window.init( Window.java:289)
         at java.awt.Window.<init>( Window.java:318)
         at java.awt.Frame.<init>( Frame.java:419)
         at java.awt.Frame.<init>( Frame.java:384)
         at javax.swing.JFrame.<init>( JFrame.java:150)
         at apcslib.DrawingTool.<init>( DrawingTool.java:45)
         at apcslib.DrawingTool.<init>( DrawingTool.java:106)
         at JumpingJacks.main( JumpingJacks.java:35)
    So I thought, maybe I'm not importing the JAR files correctly. But if I import gsdraw.jar or a different apcslib.jar that I downloaded from some random teacher's website on the internet (and that also happens to have DrawingTool in it) then it compiles and runs fine. So I thought, ok, maybe it's a problem with this one particular apcslib.jar that I transferred from my Windows computer. But like I said, DrawHouse and JumpingJacks run fine on my windows comp, and most ridiculous of all, I tried running Tasmania on my Macbook (which uses the FileInput class from your apcslib.jar) and THAT works fine! So to recap, I'm not importing the JAR files wrong and at times there doesn't seem to be anything wrong with the apcslib.jar you gave us and probably not anything wrong with my IDE, seeing that importing of other JAR files works fine (I'm using eclipse and/or xcode, and the same problem occurs with both). Now of course, I could just go ahead and use the apcslib that I downloaded from the internet, but it's very inconvenient since it doesn't match your own apcslib's contents (for example, it doesn't have FileInput). By the way, I've also tried adding the JARS directly to the Java Extensions instead of importing them as external JARS, but that doesn't solve the problem. I've also attached the apcslib.jar in case you think that it's somehow corrupted or something....
    Do you have any idea about what could be wrong or where I should go from here?
    Thanks for all your help!
    Bryan Huh

    Thanks for the reply, but if it is a problem with how
    I'm using DrawingTool, then shouldn't it run with
    errors on my Windows comp too?Maybe, maybe not. If you're doing something that's correct on one but not the other - using file names for Windows on Linux Mac), for instance.
    The same EXACT source
    code will compile and run fine on my Windows comp,
    but run with errors on my Macbook. And if it's a bug
    with DrawingTool, then shouldn't my Windows comp also
    encounter the problem and run with errors?No. the DT programmer could have done the same thing, using code that's correct on Windows but not on Linux. Or there could be a difference in the Java versions on the couputers and code that's valid in the later version is failing in the earlier, or vice versa.

  • Problems with java logging utility

    Hi,
    I am having a few problems with java's logging framework.
    When I create a logger using
    Logger log = Logger.getLogger("my.com");
    and log my messages using this "log" object, the messages are logged to System.err which is my console. But when I add a Filehandler to this Logger object, I get log messages both in the file and the standard error.
    The problem is that I want to supress logging to the standard error but do not know how to do this. I tried a few things:
    1) If I close the standard error (System.err.close() ), things work fine but I can't afford doing this since other parts of my application might use System.err for some purpose.
    2) I thought that , by default, a ConsoleHandler object is added to the Logger object. So I thought I might get around the problem if I close() this ConsoleHandler object. But, to my surprise, log.getHandlers() returns an empty array by default. So there is no ConsoleHandler attached to it.
    Any info. regarding it will be very much appreciated.
    Thanks,
    Arch.

    Logger.setUseParentHandlers(false)

  • Problem with java print

    Hi, I'm have problems with java print (g2d). For example i want to print a String "ABC**************************DEF" on paper size 80mm width (invoice paper). I can print all that string with paper A4 size, but with paper size 80mm i have problem with that String, the result is "C*****************D" lost AB and EF. I think i had problem with paper size, pls help me. Thank you so much.
    My code is below:
    package app.util;
    To change this template, choose Tools | Templates
    and open the template in the editor.
    @author HUU NGHIA
    // Printing Sample code
    // This code demonstrates the Java 2 print mechanism
    import com.connection.Product;
    import java.awt.;
    import java.awt.print.;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.Vector;
    // Define a class that is called per page that needs printing. It implements
    // the one and only method in the Printable interface : print. Note that
    // this is quite separate from the PrinterJob class print() method.
    // This method does not actually do any printing. All it does is write text
    // and/or graphics onto the passed page (graphics context). The calling
    // printer job object will then pass this page to the printer.
    public class PrinterController {
    public static void print(Vector<Product> products) {
    // Create an object that will hold all print parameters, such as
    // page size, printer resolution. In addition, it manages the print
    // process (job).
    PrinterJob job = PrinterJob.getPrinterJob();
    // It is first called to tell it what object will print each page.
    job.setPrintable(new PrintObject(products));
    // Then it is called to display the standard print options dialog.
    if (job.printDialog()) {
    // If the user has pressed OK (printDialog returns true), then go
    // ahead with the printing. This is started by the simple call to
    // the job print() method. When it runs, it calls the page print
    // object for page index 0. Then page index 1, 2, and so on
    // until NO_SUCH_PAGE is returned.
    try {
    job.print();
    } catch (PrinterException e) {
    e.printStackTrace();
    class PrintObject implements Printable {
    Vector<Product> products;
    public PrintObject(Vector<Product> products) {
    this.products = products;
    public int print(Graphics g, PageFormat f, int pageIndex) {
    Graphics2D g2 = (Graphics2D) g; // Allow use of Java 2 graphics on
    // the print pages :
    System.out.println("f.getImageableX(): " f.getImageableX());
    // A simple circle to go on the second page (index = 1).
    switch (pageIndex) {
    case 0:
    printInvoiceTemplate(g2, products);
    return PAGE_EXISTS;
    // case 1 : g2.setColor(Color.red); // Page 2 : print a circle
    // g2.draw(circle);
    // return PAGE_EXISTS;
    default:
    return NO_SUCH_PAGE; // No other pages
    public String getDate(){
    Date d = new Date();
    SimpleDateFormat sp = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
    return sp.format(d);
    private void printInvoiceTemplate(Graphics2D g2, Vector<Product> products) {
    //System.out.println("#######" cardInfo.getTranType());
    int alignY = 40;
    int alignXCenter = 60;
    int enterSpace = 15;
    int xProductName = 10;
    int xUnit = 85;
    int xAmt = 110;
    int xTotal = 155;
    int yEndData = 0;
    int totalAll = 0;
    g2.setColor(Color.black); // Page 1 : print a rectangle
    g2.setFont(new Font("Verdana", 0, 8));
    g2.drawString("ABC", alignXCenter, alignY);
    g2.drawString("123WWW", alignXCenter, alignY enterSpace *1);
    g2.drawString("Phone: (08)62891633", alignXCenter, alignY enterSpace*2);
    g2.setFont(new Font("Verdana", 1, 12));
    g2.drawString("Invoice", alignXCenter - 10, alignY enterSpace*4);
    products = new Vector<Product>();
    for (int i = 0; i < 10; i+) {
    Product product = new Product();
    product.setProductName("ZESTORETIC TAB 20MG B/28" i);
    product.setUnit("v"+i);
    product.setAmt(5+i);
    product.setPrice(50000+i);
    products.add(product);
    for (int i = 0; i < products.size(); i+) {
    System.err.println(i);
    int total = products.get(i).getAmt()*products.get(i).getPrice();
    g2.drawString(i+1+"."products.get(i).getProductName(), xProductName+2, alignY enterSpace(8+(i*2)));
    g2.drawString(products.get(i).getUnit(), xUnit+5, alignY enterSpace*(9(i*2)));
    g2.drawString(products.get(i).getAmt()"x"+AppUtils.formatPrice(products.get(i).getPrice())"", xAmt+5, alignY enterSpace*(9(i*2)));
    g2.drawString(AppUtils.formatPrice(total), xTotal+15, alignY enterSpace*(9(i*2)));
    yEndData = 9+(i*2);
    totalAll = totalAll total;
    System.out.println(yEndData);
    g2.drawLine(xProductName, alignY enterSpace*(yEndData 1), 210, alignY enterSpace*(yEndData 1));
    g2.drawString(AppUtils.formatPrice(totalAll)" VND", xAmt, alignY enterSpace*(yEndData 2));
    g2.drawString("Thank you", alignXCenter, alignY enterSpace*(yEndData 4));
    g2.drawString("***", alignXCenter 30, alignY enterSpace*(yEndData + 5));
    public static void main(String[] args) {
    PrinterController.print(null);
    }

    When you posted you didn't use code tags, as a result the forum software has interpreted some of your characters in your program as screen formatting codes and has corrupted your post--the most easily observable change is the bolded characters in you post. Please repost your code using code tags so people will be helping with uncorrupted code.

  • Problem with java swing button and loop

    Problem with java swing button and loop
    I�m using VAJ 4.0. and I�m doing normal GUI application. I have next problem.
    I have in the same class two jswing buttons named start (ivjGStart) and stop (ivjGStop) and private static int field named Status where initial value is 0. This buttons should work something like this:
    When I click on start button it must do next:
    Start button must set disenabled and Stop button must set enabled and selected. Field status is set to 1, because this is a condition in next procedure in some loop. And then procedure named IzvajajNeprekinjeno() is invoked.
    And when I click on stop button it must do next:
    Start button must set enabled and selected and Stop button must set disenabled.
    Field status is set to 0.
    This works everything fine without loop �do .. while� inside the procedure IzvajajNeprekinjeno(). But when used this loop the start button all the time stay (like) pressed. And this means that a can�t stop my loop.
    There is java code, so you can get better picture:
    /** start button */
    public void gStart_ActionEvents() {
    try {
    ivjGStart.setEnabled(false);
    ivjGStop.setEnabled(true);
    ivjGStop.setSelected(true);
    getJTextPane1().setText("Program is running ...");
    Status = 1;
    } catch (Exception e) {}
    /** stop button */
    public void gStop_ActionEvents() {
    try {
    ivjGStart.setEnabled(true);
    ivjGStart.setSelected(true);
    ivjGStop.setEnabled(false);
    getJTextPane1().setText("Program is NOT running ...");
    Status = 0;
    } catch (Exception e) {
    /** procedure IzvajajNeprekinjeno() */
    public void IzvajajNeprekinjeno() {  //RunLoop
    try {
    int zamik = 2000; //delay
    do {
    Thread.sleep(zamik);
    PreberiDat(); //procedure
    } while (Status == 1);
    } catch (Exception e) {
    So, I'm asking what I have to do, that start button will not all the time stay pressed? Or some other aspect of solving this problem.
    Any help will be appreciated.
    Best regards,
    Tomi

    This is a multi thread problem. When you start the gui, it is running in one thread. Lets call that GUI_Thread so we know what we are talking about.
    Since java is task-based this will happen if you do like this:
    1. Button "Start" is pressed. Thread running: GUI_Thread
    2. Event gStart_ActionEvents() called. Thread running: GUI_Thread
    3. Method IzvajajNeprekinjeno() called. Thread running: GUI_Thread
    4. Sleep in method IzvajajNeprekinjeno() on thread GUI_Thread
    5. Call PreberiDat(). Thread running: GUI_Thread
    6. Check status. If == 1, go tho 4. Thread running: GUI_Thread.
    Since the method IzvajajNeprekinjeno() (what does that mean?) and the GUI is running in the same thread and the event that the Start button has thrown isn't done yet, the program will go on in the IzvajajNeprekinjeno() method forever and never let you press the Stop-button.
    What you have to do is do put either the GUI in a thread of its own or start a new thread that will do the task of the IzvajajNeprekinjeno() method.
    http://java.sun.com/docs/books/tutorial/uiswing/index.html
    This tutorial explains how to build a multi threaded gui.
    /Lime

  • Problem with Java after Software Update to 10.5.7

    Hi,
    I am facing problem with Java after having run Software upgrades.
    Here is the whole story. I recently moved to iMac 10.5.6 from PowerPc 10.4. On this new machine I was having problem running a 3rd party application, which requires JVM. As this application worked well on Tiger, I decided to upgrade JVM on my iMAC using Software Upgrade(was I insane!!). As I like my systems to be updated (as with linux on my personal machine) I clicked "install all". As a result I have the following upgrades run on my machine:
    2009-05-20 13:12:01 +0200: Installed "Mac OS X Update Combined" (10.5.7)
    2009-05-20 13:12:10 +0200: Installed "Remote Desktop Client Update" (3.2.2)
    2009-05-20 13:12:26 +0200: Installed "Java For Mac OS X 10.5 Update 2" (1.0)
    2009-05-20 13:58:36 +0200: Installed "Java for Mac OS X 10.5 Update 3" (1.0)
    2009-05-20 13:58:44 +0200: Installed "AirPort Utility Software Update 2009-001" (5.4.1)
    2009-05-20 13:59:07 +0200: Installed "QuickTime" (7.6)
    2009-05-20 13:59:22 +0200: Installed "iPhoto Update" (7.1.5)
    2009-05-20 13:59:28 +0200: Installed "iLife Support" (9.0.2)
    2009-05-20 13:59:38 +0200: Installed "iDVD Update" (7.0.3)
    2009-05-20 13:59:58 +0200: Installed "iTunes" (8.1.1)
    But now, simply running $java on the prompt hangs, i.e. it takes no action.
    $ which java
    /usr/bin/java
    $ ls -ltr /usr/bin/java
    May 20 15:09 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
    $java (no response)
    Here is the output of $ top
    PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
    703 java 98.8% 0:38.54 3 110 72 480K 184K 1964K 40M
    Any clues?
    Details of JavaVM on my machine
    $ pwd
    /System/Library/Frameworks/JavaVM.framework/Versions
    $ ls -ltr
    total 56
    drwxr-xr-x 3 root wheel 102 Dec 2 2007 1.3.1
    lrwxr-xr-x 1 root wheel 3 Aug 31 2008 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 Aug 31 2008 1.4.2
    drwxr-xr-x 8 root wheel 272 Aug 31 2008 1.5.0
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.3 -> 1.3.1
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.5 -> 1.5.0
    drwxr-xr-x 8 root wheel 272 May 20 13:12 1.6.0
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.6 -> 1.6.0
    drwxr-xr-x 8 root wheel 272 May 20 13:12 A
    lrwxr-xr-x 1 root wheel 1 May 20 14:57 Current -> A
    lrwxr-xr-x 1 root wheel 3 May 20 14:59 CurrentJDK -> 1.5
    Any suggestions? Is there a cleaner approach to uninstall Java on Mac then a simpl "move to thrash"!
    cheers

    Hi,
    I am facing problem with Java after having run Software upgrades.
    Here is the whole story. I recently moved to iMac 10.5.6 from PowerPc 10.4. On this new machine I was having problem running a 3rd party application, which requires JVM. As this application worked well on Tiger, I decided to upgrade JVM on my iMAC using Software Upgrade(was I insane!!). As I like my systems to be updated (as with linux on my personal machine) I clicked "install all". As a result I have the following upgrades run on my machine:
    2009-05-20 13:12:01 +0200: Installed "Mac OS X Update Combined" (10.5.7)
    2009-05-20 13:12:10 +0200: Installed "Remote Desktop Client Update" (3.2.2)
    2009-05-20 13:12:26 +0200: Installed "Java For Mac OS X 10.5 Update 2" (1.0)
    2009-05-20 13:58:36 +0200: Installed "Java for Mac OS X 10.5 Update 3" (1.0)
    2009-05-20 13:58:44 +0200: Installed "AirPort Utility Software Update 2009-001" (5.4.1)
    2009-05-20 13:59:07 +0200: Installed "QuickTime" (7.6)
    2009-05-20 13:59:22 +0200: Installed "iPhoto Update" (7.1.5)
    2009-05-20 13:59:28 +0200: Installed "iLife Support" (9.0.2)
    2009-05-20 13:59:38 +0200: Installed "iDVD Update" (7.0.3)
    2009-05-20 13:59:58 +0200: Installed "iTunes" (8.1.1)
    But now, simply running $java on the prompt hangs, i.e. it takes no action.
    $ which java
    /usr/bin/java
    $ ls -ltr /usr/bin/java
    May 20 15:09 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
    $java (no response)
    Here is the output of $ top
    PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
    703 java 98.8% 0:38.54 3 110 72 480K 184K 1964K 40M
    Any clues?
    Details of JavaVM on my machine
    $ pwd
    /System/Library/Frameworks/JavaVM.framework/Versions
    $ ls -ltr
    total 56
    drwxr-xr-x 3 root wheel 102 Dec 2 2007 1.3.1
    lrwxr-xr-x 1 root wheel 3 Aug 31 2008 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 Aug 31 2008 1.4.2
    drwxr-xr-x 8 root wheel 272 Aug 31 2008 1.5.0
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.3 -> 1.3.1
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.5 -> 1.5.0
    drwxr-xr-x 8 root wheel 272 May 20 13:12 1.6.0
    lrwxr-xr-x 1 root wheel 5 May 20 13:12 1.6 -> 1.6.0
    drwxr-xr-x 8 root wheel 272 May 20 13:12 A
    lrwxr-xr-x 1 root wheel 1 May 20 14:57 Current -> A
    lrwxr-xr-x 1 root wheel 3 May 20 14:59 CurrentJDK -> 1.5
    Any suggestions? Is there a cleaner approach to uninstall Java on Mac then a simpl "move to thrash"!
    cheers

  • Problem with Java after System Upgrade to 10.5.7

    Hi,
    I am facing problem with Java after having run Software upgrades.
    Here is the whole story. I recently moved to iMac 10.5.6 from PowerPc 10.4. On this new machine I was having problem running a 3rd party application, which requires JVM. As this application worked well on Tiger, I decided to upgrade JVM on my iMAC using Software Upgrade(was I insane!!). As I like my systems to be updated (as with linux on my personal machine) I clicked "install all". As a result I have the following upgrades run on my machine:
    2009-05-20 13:12:01 +0200: Installed "Mac OS X Update Combined" (10.5.7)
    2009-05-20 13:12:10 +0200: Installed "Remote Desktop Client Update" (3.2.2)
    2009-05-20 13:12:26 +0200: Installed "Java For Mac OS X 10.5 Update 2" (1.0)
    2009-05-20 13:58:36 +0200: Installed "Java for Mac OS X 10.5 Update 3" (1.0)
    2009-05-20 13:58:44 +0200: Installed "AirPort Utility Software Update 2009-001" (5.4.1)
    2009-05-20 13:59:07 +0200: Installed "QuickTime" (7.6)
    2009-05-20 13:59:22 +0200: Installed "iPhoto Update" (7.1.5)
    2009-05-20 13:59:28 +0200: Installed "iLife Support" (9.0.2)
    2009-05-20 13:59:38 +0200: Installed "iDVD Update" (7.0.3)
    2009-05-20 13:59:58 +0200: Installed "iTunes" (8.1.1)
    But now, simply running $ java on the prompt hangs, i.e. it takes no action.
    $ which java
    /usr/bin/java
    $ ls -ltr /usr/bin/java
    May 20 15:09 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
    $java (no response)
    Here is the output of $ top
    PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
    703 java 98.8% 0:38.54 3 110 72 480K 184K 1964K 40M
    Any clues?
    cheers

    Hi man,
    In the wake of this java problem I resorted to keep working on my old machine, and today in my spare time I tried to fix this new machine.
    So I execute $java on prompt, and then try to check the files it has opened, using lsof -p pid
    I see it referring to
    /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
    isn't this usually the JAVA_HOME
    However, executing $/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/bin/java
    hangs!!
    but
    $/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java
    works!!
    $ pwd
    /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin
    $ ./java -version
    java version "1.6.0_07"
    Java(TM) SE Runtime Environment (build 1.6.0_07-b06-153)
    Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_07-b06-57, mixed mode)
    So, I changed the links as follows
    borgraf:Versions raveesh$ l
    total 72
    drwxr-xr-x 3 root wheel 102 Mar 6 2008 1.3.1
    lrwxr-xr-x 1 root wheel 3 May 21 19:42 1.4.1 -> 1.4
    drwxr-xr-x 8 root wheel 272 May 21 19:42 1.6.0
    lrwxr-xr-x 1 root wheel 3 May 21 19:44 OldCurrentJDK -> 1.5
    lrwxr-xr-x 1 root wheel 5 May 21 19:44 1.4 -> 1.4.2
    lrwxr-xr-x 1 root wheel 5 May 21 19:44 1.3 -> 1.3.1
    lrwxr-xr-x 1 root wheel 5 May 21 19:44 1.5 -> 1.5.0
    drwxr-xr-x 8 root wheel 272 May 21 19:44 1.4.2
    drwxr-xr-x 8 root wheel 272 May 21 19:44 1.5.0
    lrwxr-xr-x 1 root wheel 5 May 21 19:44 1.6 -> 1.6.0
    lrwxr-xr-x 1 root wheel 1 May 21 19:44 OldCurrent -> A
    drwxr-xr-x 8 root wheel 272 May 21 19:44 A
    lrwxr-xr-x 1 root wheel 3 Jun 4 17:14 CurrentJDK -> 1.6
    lrwxr-xr-x 1 root wheel 3 Jun 4 17:21 Current -> 1.6
    Linking my Current and CurrentJDK to 1.6 and it works!
    However, shall that be the reason!
    what is in your /Versions/Current/
    I got the following
    $ ls /System/Library/Frameworks/JavaVM.framework/Versions/Current
    CodeResources Frameworks JavaVM
    Commands Headers Resources
    There is no /Home in here, which is usually the case for /1.5 or /1.6
    Anyways, things seems to work for the moment. Lets see if I get problem with using Java.
    thanks

Maybe you are looking for

  • How can I get one button to perform two functions?

    here's what I want: have one button with a + that opens a pop up using a MSO and then turn that button to a X to close the pop up changing states on the MSO

  • App Error 523

    Hey Folks, Im in a bit of a bother. 3 weeks ago, i went to goa for a few days off. I had switched off my phone, and when i landed, i turned it on in order to call the hotel. When i did turn it on, i got this white screen which simply said "app error

  • Asa 5520 "loosing" code after code has been put in and operating

    Sorry to ask this if it has all ready been covered.  We have an asa 5520 running 8.3.2(1) code.  Three times now I have entered code and rules in our asa and had things working, only to have the code "dissapear" and thus things stop working.  We upgr

  • BC4J/Struts java.lang.ClassCastException in UpdateAction

    Dear reader, I am facing a problem that I can't address. I have an entity object named 'Employee' and on the password field, there is one validation rule (a method, which checks if the passwords length is between 6 and 12 characters). I have a view c

  • Ipod is disabled.....Have tried to restore....Please Help!!

    Hi, My neice asked me to help fix her ipod. It says ipod disabled please connect to itunes. This is the 2nd time it has happened, 1st time her friend restored through itunes but my neice has managed to disable it again! This time im trying to fix it