Time for Java

Hey,
I've been developing a Timing and Synchronisation package, I've just discovered that System.currentTimeMillis() is too inaccurate, so i've implemented something using jni and the windows libraries. On desktop machines it works perfect but on a Dell laptop running xp of mine the results are erratic and hidiously unhelpfully! I know that this is most likely a hardware issue, but i'm under presssure to produce something releasable shortly.
Does anyone have ANY ideas on the issue?
Thanks,
M
ps all machines are using 1.4.2 and it works proberly on desktops running w2k and xp

The more i look into it the more seems to be specific to my personel laptop! The only difference i can think that might be causing the problem is that the machine has a kind-of pusedo-dual-processer set up which i read on the msdn site can cause problems when using the methods below. Anyway I have included a copy of the c++ code below
It doesn't feel right posting c code here but hey...
#include <jni.h>
#include "HiResTimer.h"
#include <windows.h>
// HiResCounter
class _HiResCounter{
public:
_HiResCounter()
{ m_bExists = QueryPerformanceFrequency(
&m_Freq ); }
BOOL Exists()
{ return m_bExists; }
double Freq()
{ return (double)(m_Freq.QuadPart); }
protected:
BOOL m_bExists;
LARGE_INTEGER m_Freq;
static _HiResCounter HiResCounter;
// Class: HiResTimer
// Method: isHighResTimerAvailable
// Signature: ()Z
JNIEXPORT jboolean JNICALL
Java_HiResTimer_isHighResTimerAvailable
(JNIEnv *, jobject)
return HiResCounter.Exists();
// Class: HiResTimer
// Method: startTiming
// Signature: ()D
JNIEXPORT jdouble JNICALL Java_HiResTimer_startTiming
(JNIEnv *, jobject)
LARGE_INTEGER li;
if( HiResCounter.Exists() ) {
QueryPerformanceCounter( &li );
return (double)(li.QuadPart);
} else {
return (double)GetTickCount();
} // else
// Class: HiResTimer
// Method: endTiming
// Signature: (D)D
JNIEXPORT jdouble JNICALL Java_HiResTimer_endTiming
(JNIEnv *, jobject, jdouble dStart )
LARGE_INTEGER li;
if( HiResCounter.Exists() ) {
QueryPerformanceCounter( &li );
return ((li.QuadPart - dStart) * 1000.0 /
HiResCounter.Freq());
} else {
return (GetTickCount() - (DWORD) dStart);
} // else
// DllMain
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
switch (ul_reason_for_call)
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
return TRUE;

Similar Messages

  • System time for Java Stack and ABAP Stack of PI

    HI,
         We have a scenario in which we have a synchronous flow of data. In the forward flow we have used field UZEIT in an RFC Lookup to register the inbound time and in the reverse flow we have used current time function of SAP PI mapping. PI time is the local time of the server, However UZEIT is 4 hours ahead compared to PI time.
    Both the Java and the Abap stack are installed on the same server.
    Kindly let us know the reason for the difference in time on both the stacks.
    Regards,
                Milan Thaker

    Hi,
       Yes I am refering to the System->Status time in ABAP Stack. Could you please tell me where can I check the System time of JAVA stack. I got one XML file in UME which refers to some timestamp in com.sap.security.core.usermanagement but I failed to locate this field. Please let me know where can I find the Java stack time and how can that be synchronized with ABAP.
             Also, is there any time zone settting in JAVA for UTC , the way we have in ABAP
    Regards,
                  Milan Thaker

  • How to find the Execution Time for Java Code?

    * Hi everyone , i want to calculate the execution time for my process in java
    * The following was the ouput for my coding,
    O/P:-
    This run took 0 Hours ;1.31 Minutes ;78.36 Seconds
    *** In the above output , the output should come exactly what hours , minutes and seconds for my process,
    but in my code the minutes are converted into seconds(It should not)...
    * Here is my coding,
        static long start_time;
        public static void startTime()
            start_time = System.currentTimeMillis();
        public static void endTime()
            DecimalFormat df = new DecimalFormat("##.##");
            long end_time = System.currentTimeMillis();
            float t = end_time - start_time;
            float sec = t / 1000;
            float min = 0, hr = 0;
            if (sec > 60) {
                min = sec / 60;
            if (min > 60) {
                hr = min / 60;
            System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
        }* How to Calcualte exact timing for my process....
    * Thanks

    * Hi flounder, Is following code will wotk perfectly?
         public static void endTime()
              DecimalFormat df = new DecimalFormat("##.##");
              long end_time = System.currentTimeMillis();
              float t = end_time - start_time;
              float sec = t / 1000;
              float min = 0, hr = 0;
              while(sec >= 60){
         min++;
         sec = sec -60;
         if (min >= 60){
         min = 0; //or min = min -60;
         hr++;
              System.out.println("This run took " + df.format(hr) + " Hours ;"+ df.format(min) + " Minutes ;" + df.format(sec) + " Seconds");
         }

  • How to Find Idle Time for Java Application

    Hi
    I have tried various type of methods to find IDLE Time but no use
    Can any one please help me
    Krishna

    E.D.-inc wrote:
    how to set a file association for a specifed file type in windows??
    i am asking this because i cant set a file association to a .jar application, it has to be an exe.. is it a must to convert it to exe??
    can anyone help me?? is it possible to trick this??Open any "folder", go to Extras -> Folder Options
    Select Data/Mime Types
    Select Add/New

  • Daylight Savings Time patch for Java

    This DST patch for java has me totally confused. I downloaded and installed tzupdater2006p, which according to the README it was suppose to cover 1.3.1_18 through 1.4 . All went well until I found one the servers, a Solaris 8 one, running 1.3.1_01. I've been searching for a patch for that but can't seem to find one. Can anyone point me in the right direction?

    No that looks like the earliest it goes to according to the what it lists. I just did this the other day in support of some vendors application software that we use. If you have a paying account with Sun, perhaps you can open a contact with them.
    But here's a caveat ... after I had applied that patch to my Java, the vendor told me that they won't support it - that is, they did not test using it, and so recommended upgrading to 1.4.2_12. You might want to explore that possibility on your side too.
    ~Bill

  • XModem via TCP for Java

    I am sure that many of you experienced developers have read requests in the past concerning implmentation of Ward Christenen's XModem protocol over a TCP socket. If not, well... you are about to...
    This is a major hack... but it is starting to come together... thanks to Fred Potter for his source code to start this project...
    Objective:
    Basically, I want to create a console application which accepts an incoming connection and starts the receive mode for a XModem file transfer. I am using CGTerm (for Commodore retrocomputing) but can test with HyperTerminal as well...
    The user who connects to the server selects SEND and the FILE to send for a XModem file transfer... and the transfer begins...
    The incoming blocks of 128 bytes are written to a file
    After the transfer is over the server disconnects the client terminal.
    Here is what I have so far:
    import java.net.*;
    import java.lang.*;
    import java.io.*;
    // X-Modem Server implementation via TCP/IP socket
    public class XServer {
    public static FileWriter fw;
    public static void main(String[] args) throws IOException {
    // define the file
    try {   
    fw = new FileWriter("filename.txt");
    } catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    int port = Integer.parseInt(args[0]);
    ServerSocket server = new ServerSocket(port);
    System.out.println("X-Server v1.0 - waiting for connection");
    Socket client = server.accept();
    // Handle a connection and exit.
    try {
    InputStream inputStream = client.getInputStream();
    OutputStream outputStream = client.getOutputStream();
    new PrintStream(outputStream).println("Go to send file mode!"); // sent to client
    System.out.println("Ready to receive file via X-Modem...");
    * BEGIN TRANSFER HERE!
    // set the debug flag
    XModem.debug = true;
    * Here we are instantiating a new InputStream that represents the remote
    * file that we are receiving. In this single line we are attempting to
    * start the flow.
    * Behind The Scenes: We're sending a NAK across the serial line repeatedly
    * until we finaly start seeing the data flow. If we don't see the data
    * flow, then we throw an exception.
    System.out.println("Sending NAK to start receive mode...");
    InputStream incomingFile;
    try {
    incomingFile = new XModemRXStream(inputStream, outputStream);
    } catch (IOException e) {
    System.out.println("ERROR! Unable to start file transfer!");
    e.printStackTrace();
    return;
    System.out.println("Starting file transfer...");
    * Here we are reading from the incoming file, byte by byte, and printing out.
    * Behind The Scenes: Internally, the read() method is handling the task of
    * asking for the next data block from the remote computer, processing it (i.e.
    * parsing, running checksums), and then putting it in an internal buffer. Not
    * all calls to read() will request a new data block as each block contains at
    * least 128 bytes of data. Sometimes you will only hit the buffer.
    try {
    for (;;) {
    int c = incomingFile.read();
    if (c==-1)
    break; // End of File
    // print character / byte
    System.out.print(c+",");
    // write to file
    try {       
    //System.out.print(".");
    fw.write(c);
    } catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    } catch (IOException e) {
    System.out.println("error while reading the incoming file.");
    e.printStackTrace();
    return;
    // done
    System.out.println("File sent.");
    new PrintStream(outputStream).println("");
    new PrintStream(outputStream).println("transfer successful!");
    } finally {
    //client.close();
    // save the file
    try {   
    fw.close();
    System.out.println("file saved.");
    } catch (Exception e) {
    System.out.println(e);
    System.exit(0);
    * XModem keeps track of settings that the Receive and Transmit Stream classes will
    * reference.
    * <p>Copyright: Copyright (c) 2004</p>
    * @author Fred Potter
    * @version 0.1
    class XModem {
    public static boolean debug = false;
    * XModemRXStream is an easy to use class for receiving files via the XModem protocol.
    * @author Fred Potter
    * @version 0.1
    class XModemRXStream
    extends InputStream {
    // CONSTANTS
    private static final int SOH = 0x01;
    private static final int EOT = 0x04;
    private static final int ACK = 0x06;
    private static final int NAK = 0x15;
    private static final int CAN = 0x18;
    private static final int CR = 0x0d;
    private static final int LF = 0x0a;
    private static final int EOF = 0x1a;
    // block size - DON'T CHANGE - I toyed with the idea of adding 1K support but the code is NOT there yet.
    private static final int bs = 128;
    // PRIVATE STUFF
    private int ebn; // expected incoming block #
    private byte[] data; // our data buffer
    private int dataPos; // our position with the data buffer
    private InputStream in;
    private OutputStream out;
    * Creates a new InputStream allowing you to read the incoming file. All of the XModem
    * protocol functions are handled transparently.
    * As soon as this class is instantiated, it will attempt to iniatate the transfer
    * with the remote computer - if unsuccessful, an IOException will be thrown. If it
    * is successful, reading may commense.
    * NOTE: It is important not to wait too long in between calls to read() - the remote
    * computer will resend a data block if too much time has passed or even just give up
    * on the transfer altogether.
    * @param in InputStream from Serial Line
    * @param out OutputStream from Serial Line
    public XModemRXStream(InputStream in, OutputStream out) throws
    IOException {
    this.in = in;
    this.out = out;
    // Initiate the receive sequence - basically, we send a NAK until the data
    // starts flowing.
    init:for (int t = 0; t < 10; t++) {
    if (XModem.debug) {
    System.out.println("Waiting for response [ try #" + t + " ]");
    long mark = System.currentTimeMillis();
    out.write(NAK);
    // Frequently check to see if the data is flowing, give up after a couple seconds.
    for (; ; ) {
    if (in.available() > 0) {
    break init;
    try {
    Thread.sleep(10);
    catch (Exception e) {}
    if (System.currentTimeMillis() - mark > 2000) {
    break;
    // We have either successfully negotiated the transfer, OR, it was
    // a failure and timed out. Check in.available() to see if we have incoming
    // bytes and that will be our sign.
    if (in.available() == 0) {
    throw new IOException();
    // Initialize some stuff
    ebn = 1; // the first block we see should be #1
    data = new byte[bs];
    dataPos = bs;
    * Reads the next block of data from the remote computer. Most of the real XModem protocol
    * is encapsulated within this method.
    * @throws IOException
    private synchronized void getNextBlock() throws IOException {
    if (XModem.debug) {
    //System.out.println("Getting block #" + ebn);
    // Read block into buffer. There is a 1 sec timeout for each character,
    // otherwise we NAK and start over.
    byte[] buffer;
    recv:for (; ; ) {
    buffer = new byte[bs + 4];
    for (int t = 0; t < 10; t++) {
    System.out.println("\nReceiving block [ #" + ebn + " ]");
    // Read in block
    buffer = new byte[buffer.length];
    for (int i = 0; i < buffer.length; i++) {
    int b = readTimed(1);
    // if EOT - don't worry about the rest of the block.
    if ( (i == 0) && (b == EOT)) {
    buffer[0] = (byte) (b & 0xff);
    break;
    // if CAN - the other side has cancelled the transfer
    if (b == CAN) {
    throw new IOException("cancelled");
    if (b < 0) {
    if (XModem.debug) {
    System.out.println("Time out... NAK'ing");
    out.write(NAK);
    continue recv;
    else {
    buffer[i] = (byte) (b & 0xFF);
    break;
    int type = buffer[0] & 0xff; // either SOH or EOT
    if (type == EOT) {
    if (XModem.debug) {
    System.out.println("EOT!");
    out.write(ACK);
    break;
    int bn = buffer[1] & 0xff; // block number
    int bnc = buffer[2] & 0xff; // one's complement to block #
    if (
    (bn != ebn) && (bn != (ebn - 1)) ||
    (bn + bnc != 255)) {
    if (XModem.debug) {
    System.out.println("NAK'ing type = " + type + " bn = " + bn +
    " ebn = " +
    ebn + " bnc = " + bnc);
    out.write(NAK);
    continue recv;
    byte chksum = buffer[ (buffer.length - 1)];
    byte echksum = 0;
    for (int i = 3; i < (buffer.length - 1); i++) {
    echksum = (byte) ( ( (echksum & 0xff) + (buffer[i] & 0xff)) & 0xff);
    if (chksum != echksum) {
    out.write(NAK);
    continue recv;
    out.write(ACK);
    if (ebn == 255) {
    ebn = 0;
    else {
    ebn++;
    break;
    // We got our block, now save it in our data buffer.
    data = new byte[bs];
    for (int i = 3; i < (buffer.length - 1); i++) {
    data[(i - 3)] = buffer;
    dataPos = 0;
    public synchronized int read() throws IOException {
    // If at the end of our buffer, refill it.
    if (dataPos == bs) {
    try {
    getNextBlock();
    catch (IOException e) {
    throw new IOException();
    // If we're still at end of buffer, say so.
    if ( dataPos == bs) {
    return -1;
    int d = data[dataPos];
    if (d == EOF)
    return -1;
    dataPos++;
    return d;
    * A wrapper around the native read() call that provides the ability
    * to timeout if no data is available within the specified timeout value.
    * @param timeout timeout value in seconds
    * @throws IOException
    * @return int an integer representing the byte value read.
    private int readTimed(int timeout) throws IOException {
    long start = System.currentTimeMillis();
    for (; ; ) {
    if (in.available() > 0) {
    return (in.read());
    try {
    Thread.sleep(10);
    catch (InterruptedException ex) {
    //if (System.currentTimeMillis() - start > timeout * 1000) {
    if (System.currentTimeMillis() - start > timeout * 5000) {
    return -1;
    Here was the output...
    Original file:
    (Commodore CBM SEQ file exported to PC using DirMaster)
    ��
    � �
    � ��� �� �� ��� ��
    � �� �� ���� �� ��� ��
    � ��� ����������������������������������������������
    �� ����� ������� ����� �� ����� ������ ����� ���
    � �� ������ ������ ��� ��� �� ��� ���� �� ������
    � � ���
    ����
    � � ��OWERED BY �OLOR 64 ��� V8
    �UNNING �ETWORK64 V1.26A

    �UPPORTING 38400 �AUD �ATES
    �����/����/�������

    �ESTING �CHO-�ET V1 BETA

    �EATURING �ESSAGES, �ILES,
    �ET�AIL, AND �NLINE �AMES!
    �YS�P: � � � � � � � � �

    �RESS ANY KEY TO LOGIN\C�
    The result when the file was uploaded and received by my XServer:
    ? ? ??OWERED BY ?OLOR 64 ??? V8
    ?UNNING ?ETWORK64 V1.26A
    ?UPPORTING 38400 ?AUD ?ATES
    ?ESTING ?CHO-?ET V1 BETA
    ?EATURING ?ESSAGES, ?ILES,
    ?ET?AIL, AND ?NLINE ?AMES!
    ?YS?P: ? ? ? ? ? ? ? ? ?
    ?RESS ANY KEY TO LOGIN\C?
    The result is different!
    Can someone help me along here... I have been trying to figure out how to do this for approx. a year or so... it has been a very slow process.
    I could use a guru to help me out so I can write the upload and download routines for my Commodore BBS PETSCII Emulation Server.
    Visit http://www.retrogradebbs.com for details.
    Thanks.
    Please help out a dedicated developer who is in over his head...
    -Dave

    Ok. Fair enough. What about general information about Xmodem. This is a hard project because of how obscure the legacy technology is that I am having to implement using Java and MySQL.
    I have two major issues which I have to figure out how to troubleshoot and debug, if possible.
    1. The 23+ blocks exception when a file is being received
    2. The exception which is thrown immediately if I try to receive a binary file instead of an ASCII file.
    I read that telnet is a 7-bit technology and that is why Xmodem, which is an 8-bit technology is not that popular as a viable protocol via telnet, whereas Kermit is, since it was developed for 7-bit systems, i.e. mainframes and minicomputers.
    Is this correct?
    If that is the case, why does www.serio.com have a viable X-Y-ZModem library available (for several hundred $$$ of course) which can be used with both RS-232 serial ports and TCP socket ports? Obviously, it can be done. They are the ONLY company with this library for sale for Java to do this. I cannot justify that $$$ amount for a mere hobby (writing the BBS emulation server for supporting Commodore PETSCII (CG) callers via CGTerm or a native C-64 terminal program using Jim Brain's TCPSER middleware, which emulates a Hayes modem via telnet for telBBSing/retrocomputing.
    I really want to learn how to implement a file transfer protocol, since back in the 80s, I used Xmodem, Punter, Y/Z Modem, etc., a lot to upload and download files via modem at baud rates of 2400, 14.4, 19.2, and 38.4, respectively.
    It's fun to learn how the old skool gurus of telecommunications technology did it. It is one thing to run a BBS which supports these technologies and features, and it is an entirely other thing to learn how to design and develop them yourself for implementation into a project such as I taken on.
    It CAN be done. It WILL be done. However, I have just started my exhaustive research on how it needs to be done. I have read up as much as I could on XModem by Ward C., the father of the protocol.
    But, I have no information to help me figure out why the communications are acting as they do so far.
    Can someone please download the xserver.zip file on my website at:
    www.retrogradebbs.com/projects/xserver.zip
    Compile it. Run it. Connect using HyperTerminal, Netrunner, or another telnet terminal emulation program which supports Xmodem file transfers using WinSock.
    See what happens. With finals due in the next two days, this project will have to be put on hold until after I submit my two final projects.
    If anyone knows what needs to be done to support both ASCII and BINARY file transfers via Xmodem via a socket instead of a modem with RTS/CTS hardware flow control, please respond.
    I know for a fact that this can be done.
    - Dave

  • I just ran a software update for Java and MacBook Pro SMC, now my Mini Display Port to HDMI TV is not working. The TV is flickering. The Mac Display is fine.

    I was just watching / streaming TV off Safari on my actual TV.
    I'm using a Mini-Display Port to HDMI cable for the connection to the external display.
    Software update popped-up and said there was an update for Java and for SMC.
    I ran the update and upon the computer restarting, my external display (my TV) is no longer working. It is now flickering.
    It won't work in Mirroring or set up as an extended display.
    I've reset SMC / PRAM / Safe Mode / Even restored from a Time Machine backup (From before the updates were done).
    What could it be?!

    I keep saying this over and over, in the hope that people who do a search will find it.  Apple cannot possibly test for or be reponsible for the bazillion combinations of adapter, cables, and TV's out there.  The only monitors that are 100% guaranteed to work with the MacBook Pro are the Cinema Displays and Thunderbolt Displays, because, they're made by Apple.  They're expensive, but they work perfectly.
    My guess is that you bought a cheap MDP to HDMI cable, or have a defective one.  From my reading of these boards over the past few months, cheap cables have a high failure rate.  And the regular priced ones have only a slightly less of one.  Try a new one.  Make sure you do not damage the Thunderbolt port.

  • Ebusiness Suite SDK for Java session management

    Hi, I am trying to try sample java application mentioned in Oracle® E-Business Suite Software Development Kit for Java Release 11i and 12 Part No. E28169-02
    Current version i am trying is Jdeveloper 11.1.1.4.0 and Ebiz suite 12.1.3
    able to create Apps Data source with out any issue.
    when Home.jsp is accessed through application menu, user name and all session related information is showing as NULL.
    how to resolve this issue.

    Hi Shay,
    I gone through the webinar.
    Here is more explanation of my issue.
    I created Apps Data source earlier. That time i registered external node in ebusiness suite with node_name as ip_address of weblogic server.
    But that time session details came as Null on sample Java application.
    Then i realized that may be the issue and corrected registration of external node and corrected ebiz profile options accordingly.
    When i tried to create Apps data source with fresh dbc file, i got into invalid username/pwd issue.
    As per following forum discussion topic, hyphen and dots in host name will cause issue with Apps data source creation, which is confirmed by couple of discussion participants and Juan also.
    https://kr.forums.oracle.com/forums/thread.jspa?threadID=2489849&start=30&tstart=0
    My weblogic host name is like WL-SOADEV-01.domainname.com
    what should be my further actions to resolve this issue.
    Thanks
    Maheedhar.J

  • How to change the view criteria at run time for af:query

    Hi,
    I've a usecase where I need to change the view criteria of the af:query at run time.
    Use case:
    =======
    1) Consider a check box (Show Emps Under Dept 10) in the query panel when user selects and clicks 'Search' button should show the employees under dept 10. If user searches without selecting the check box, the results should show all the employees in all the departments.
    2) I need to have a check box always in the query panel. Its mandatory.
    The way I implemented:
    ==============
    1) Created a transient variable 'Show Emps Under Dept 10' in the EmployeeVO and also created a bind variable bind_DeptNo.
    2) Create a view criteria 'AllEmployees' which has only the transient attribute as the view criteria item and whose value set to 'false' by default.
    3) Created another view criteria 'EmpUnderDept' which has 'DepartmentId' as the view criteria item and whose value set to the bind variable 'bind_DeptNo'.
    4) Dropped the view criteria 'EmpUnderDept' as the 'af:query' panel in the jspx page.
    5) Overridden the queryListener as '#{EmpBean.empSearch}'
    6) Has the below code in the empSearch method as below. When user selects the check box, applying the other criteria 'EmpUnderDept' and setting the bind variable to '10'.
    public void empSearch(QueryEvent queryEvent) {
    // Add event code here...
    QueryDescriptor queryDesc = (QueryDescriptor) queryEvent.getDescriptor();
    ConjunctionCriterion conCrit = queryDesc.getConjunctionCriterion();
    List<Criterion> criterionList = conCrit.getCriterionList();
    List criterionValues = new ArrayList();
    Object criteriaValue = null;
    int criteriaNo = 0;
    DCBindingContainer bc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    FacesContext facesContext = FacesContext.getCurrentInstance();
    for (Criterion criterion : criterionList) {
    AttributeDescriptor attrDescriptor = ((AttributeCriterion)criterion).getAttribute();
    System.out.println("============== attrDescriptor.getName() =================== " + attrDescriptor.getName());
    criteriaValue = ((AttributeCriterion)criterion).getValues().get(0);
    if(criteriaNo==0) {
    Boolean val = (Boolean) ((AttributeCriterion)criterion).getValues().get(0);
    if (val.equals(true)) {
    OperationBinding method = (OperationBinding) ADFUtil.findOperation("ExecuteWithParams");
    if(method!=null) {
    Map params = method.getParamsMap();
    //params.put(key, value)
    method.getParamsMap().put("bind_DeptId", 10L);
    method.execute();
    ADFUtil.invokeMethodExpression( "#{bindings.EmpUnderDeptCriteiaQuery.processQuery}", queryEvent);
    } else {
    //ADFUtil.invokeEL("#{bindings.ExecuteWithParams.execute}");
    ADFUtil.invokeMethodExpression( "#{bindings.AllEmployeesCriteriaQuery.processQuery}", queryEvent);
    But this approach is not working and its always showing all the employees in all the departments.
    Please let me know if there is a way to change the view criteria at run time depending on the values set at run time for one of the view criteria items.
    JDev version am using is '11.1.1.5'
    Thanks,
    Lakshman

    Hi Shay,
    It worked for me without overriding the executeQuery() method in the ViewImpl.java.
    Instead of creating 2 view criteria, I created only one which has both transient variable and the DepartmentId = <bind_DeptId>. With the above code, it worked properly. Now I am using only one view criteria.
    Thank you.

  • How to change system time through java program

    Hi
    I want to know, how to change system time through java program.
    give me a idia with example.
    Thanks

    There isn't any core Java API for this. Use JNI or call an external process with Runtime.exec().
    ~

  • Finalize() method being called multiple times for same object?

    I got a dilly of a pickle here.
    Looks like according to the Tomcat output log file that the finalize method of class User is being called MANY more times than is being constructed.
    Here is the User class:
    package com.db.multi;
    import java.io.*;
    import com.db.ui.*;
    import java.util.*;
    * @author DBriscoe
    public class User implements Serializable {
        private String userName = null;
        private int score = 0;
        private SocketImage img = null;
        private boolean gflag = false;
        private Calendar timeStamp = Calendar.getInstance();
        private static int counter = 0;
        /** Creates a new instance of User */
        public User() { counter++;     
        public User(String userName) {
            this.userName = userName;
            counter++;
        public void setGflag(boolean gflag) {
            this.gflag = gflag;
        public boolean getGflag() {
            return gflag;
        public void setScore(int score) {
            this.score = score;
        public int getScore() {
            return score;
        public void setUserName(String userName) {
            this.userName = userName;
        public String getUserName() {
            return userName;
        public void setImage(SocketImage img) {
            this.img = img;
        public SocketImage getImage() {
            return img;
        public void setTimeStamp(Calendar c) {
            this.timeStamp = c;
        public Calendar getTimeStamp() {
            return this.timeStamp;
        public boolean equals(Object obj) {
            try {
                if (obj instanceof User) {
                    User comp = (User)obj;
                    return comp.getUserName().equals(userName);
                } else {
                    return false;
            } catch (NullPointerException npe) {
                return false;
        public void finalize() {
            if (userName != null && !userName.startsWith("OUTOFDATE"))
                System.out.println("User " + userName + " destroyed. " + counter);
        }As you can see...
    Every time a User object is created, a static counter variable is incremented and then when an object is destroyed it appends the current value of that static member to the Tomcat log file (via System.out.println being executed on server side).
    Below is the log file from an example run in my webapp.
    Dustin
    User Queue Empty, Adding User: com.db.multi.User@1a5af9f
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    User Dustin destroyed. 0
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 1
    User Dustin destroyed. 1
    User Dustin destroyed. 1
    User Dustin destroyed. 1
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    User Dustin destroyed. 2
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    User Dustin destroyed. 3
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    User Dustin destroyed. 4
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    User Dustin destroyed. 5
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    User Dustin destroyed. 6
    Joe
    USER QUEUE: false
    INSIDE METHOD: false
    AFTER METHOD: false
    User Dustin pulled from Queue, Game created: Joe
    User Already Placed: Dustin with Joe
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    User Dustin destroyed. 7
    INSIDE METHOD: false
    INSIDE METHOD: false
    USER QUEUE: true
    INSIDE METHOD: false
    INSIDE METHOD: false
    User Dustin destroyed. 9
    User Joe destroyed. 9
    User Dustin destroyed. 9
    User Dustin destroyed. 9
    User Dustin destroyed. 9
    User Dustin destroyed. 9
    INSIDE METHOD: true
    INSIDE METHOD: false
    USER QUEUE: true
    INSIDE METHOD: false
    INSIDE METHOD: false
    INSIDE METHOD: true
    INSIDE METHOD: false
    USER QUEUE: true
    INSIDE METHOD: false
    INSIDE METHOD: false
    It really does seem to me like finalize is being called multiple times for the same object.
    That number should incremement for every instantiated User, and finalize can only be called once for each User object.
    I thought this was impossible?
    Any help is appreciated!

    Thanks...
    I am already thinking of ideas to limit the number of threads.
    Unfortunately there are two threads of execution in the servlet handler, one handles requests and the other parses the collection of User objects to check for out of date timestamps, and then eliminates them if they are out of date.
    The collection parsing thread is currently a javax.swing.Timer thread (Bad design I know...) so I believe that I can routinely check for timestamps in another way and fix that problem.
    Just found out too that Tomcat was throwing me a ConcurrentModificationException as well, which may help explain the slew of mysterious behavior from my servlet!
    The Timer thread has to go. I got to think of a better way to routinely weed out User objects from the collection.
    Or perhaps, maybe I can attempt to make it thread safe???
    Eg. make my User collection volatile?
    Any opinions on the best approach are well appreciated.

  • Setting up a testing server in Dreamweaver for Java Development

    Hey there,
    I'm new to Java however, I'm look forward to learning I've been trying to set-up a testing server for Java on my local machine in Dreamweaver but am having some problems! Can anyone outline the steps required in order to do this. I'd really appreciate it.
    I did follow the following link http://www.coderanch.com/forums/jforum?module=posts&action=insert&forum_id=33 and went through the troubleshooting section at the bottom. However my Java code does not display in Dreamweaver's 'Live View'
    Thanks in advance to anyone willing to take the time.
    Mike

    Hey Murray,
    Thanks for the link to the Dreamweaver Forum
    The link I provided you with earlier was in error I should placed this link instead:
    http://www.adobe.com/devnet/dreamweaver/articles/setup_testing_server.html
    Thanks for your assistance.
    Mike

  • Setting up a testing server in Dreamweaver for JAVA Development (NOT JavaScript)

    Hey there,
    I'm new to Java however, I'm look forward to learning I've been trying to set-up a testing server for Java on my local machine in Dreamweaver but am having some problems! Can anyone outline the steps required in order to do this. I'd really appreciate it.
    I did follow the following link http://www.adobe.com/devnet/dreamweaver/articles/setup_testing_server.html and went through the troubleshooting section at the bottom. However my Java code does not display in Dreamweaver's 'Live View'
    Thanks in advance to anyone willing to take the time.
    Mike

    Hey Murray,
    Thanks for the link to the Dreamweaver Forum
    The link I provided you with earlier was in error I should placed this link instead:
    http://www.adobe.com/devnet/dreamweaver/articles/setup_testing_server.html
    Thanks for your assistance.
    Mike

  • How do I rewrite current code for java 1.3

    I'm using the code below that is written for java 1.4. I have been told that the company can not push JRE 1.4 to the company, and that I need to write my code for java 1.3. I'm using org.w3c.dom for my create xml, etc.
    Is there a java 1.3 option to the 1.4? Any help would be very appreciated.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.List;
    import java.io.*;
    import java.util.*;
    import javax.xml.parsers.*;
    import javax.xml.transform.*;
    import javax.xml.transform.dom.*;
    import javax.xml.transform.stream.*;
    import org.w3c.dom.*;
    public class Sametime extends JFrame implements ActionListener {
        private int indentation = -1;
        JPanel panel = new JPanel();
        JTextArea jta = new JTextArea(
        //Instructions for user
        "For a successful buddy list migration do the following:\n"
        + "1. Save your current Sametime Buddy List to your PC.\n   "
        + "The default location should be: C:/Program Files/Lotus/Sametime Client.\n"
        + "  A. Open the Sametime Client.\n"
        + "  B. Click on People\n"
        + "  C. Click on Save List.\n"
        + "  D. Save as your first.last.dat\n"
        + "     Ex. john.doe.dat\n"
        + "NOTE: If you have AOL contacts in your Sametime buddy list they will not be migrated.\n");
        JButton browse = new JButton("Continue");
        JButton exit = new JButton("Exit");
        public Sametime() {
            super("Sametime Buddy List Migration");
            setSize(610, 245);
            Container c = this.getContentPane();
            c.add(panel);
            browse.addActionListener(this);
            exit.addActionListener(this);
            panel.add(jta);
            panel.add(browse);
            panel.add(exit);
            jta.setEditable(false);
            setLookAndFeel();
            setVisible(true);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        } //end Sametime
        public class DATFilter extends javax.swing.filechooser.FileFilter {
            public boolean accept(File f) {
                //if it is a directory -- we want to show it so return true.
                if (f.isDirectory())
                    return true;
                String extension = getExtension(f);//get the extension of the file
                //check to see if the extension is equal to "dat"
                if ((extension.equals("dat")))
                    return true;
                //default -- fall through. False is return on all
                //occasions except:
                //a) the file is a directory
                //b) the file's extension is what we are looking for.
                return false;
            }//end accept
            public String getDescription() {
                return "dat files";
            }//end getDescription
             * Method to get the extension of the file, in lowercase
            private String getExtension(File f) {
                String s = f.getName();
                int i = s.lastIndexOf('.');
                if (i > 0 &&  i < s.length() - 1)
                    return s.substring(i+1).toLowerCase();
                return "";
            }//end getExtension
        }//end class DATFilter
        public void actionPerformed(ActionEvent e) {
            //Default Location for JFileChooser search
            String error = "The file selected is not a .dat file!\n"
            + "Please select your recently saved .dat file and try again.";
            JFileChooser fc = new JFileChooser("/Program Files/Lotus/Sametime Client");
            fc.setFileFilter(new DATFilter());
            fc.setFileSelectionMode( JFileChooser.FILES_ONLY);
            String user = System.getProperty("user.name");// finds who the current user is
            if (e.getSource() == browse) {
                int returnVal = fc.showSaveDialog(Sametime.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    //if (fc.getSelectedFile().getName().equals(".dat")){
                    if (fc.getSelectedFile().getName().endsWith(".dat")){ // checks to see if selected file is .dat
                    }else{
                        JOptionPane.showMessageDialog(null, error, "Wrong File", JOptionPane.ERROR_MESSAGE);
                        return;
                    }//end else
                    try {
                        String[] contactArray = parseDatFile(fc.getSelectedFile());
                        Document document = createXMLDocument(contactArray);
                        saveToXMLFile(
                        document,
                        new File(
                        "C:/Documents and Settings/" + user +"/My Documents/OLCS/",// looks for directory for list
                        "contacts-list_migration.ctt"));
                    } catch (Exception exc) {
                        File f = new File("C:/Documents and Settings/" + user +"/My Documents/OLCS/");// setting directory for list if not there
                        boolean yes = true;
                        yes = f.mkdir();// creating directory
                        try {
                            String[] contactArray = parseDatFile(fc.getSelectedFile());
                            Document document = createXMLDocument(contactArray);
                            saveToXMLFile(
                            document,
                            new File(
                            "C:/Documents and Settings/" + user +"/My Documents/OLCS/",// used only if the directory didn't exist
                            "contacts-list_migration.ctt"));
                            //exc.printStackTrace();// not sure if this is needed?
                        } catch (Exception exc1) {
                            exc1.printStackTrace();
                        }//end inner catch
                    }// end catch
                }// end if
                if(returnVal==JFileChooser.CANCEL_OPTION){
                    String Warning = "You did not migrate your Sametime buddy list at this time.";
                    JOptionPane.showMessageDialog(null, Warning, "Migration Canceled", JOptionPane.WARNING_MESSAGE);
                    return;
                }else{
                    String thankyou = "Thank You for Migrating your Sametime buddy list to OLCS"
                    + "\nYour new OLCS buddy list has been saved to:"
                    + "\nC:/Documents and Settings/" + user +"/My Documents/OLCS"
                    + "\n as: Contact-List_migration.ctt"
                    + "\n\n To be able to use Contact-List_migration.ctt for Windows Messenger:"
                    + "\n1. Log into Windows Messenger."
                    + "\n2. Click on File"
                    + "\n3. Click on 'Import Contacts from a Saved File...'"
                    + "\n4. Open OLCS in My Documents"
                    + "\n5. Click on 'Contact-list_migration.ctt'"
                    + "\n6. Click Open to import the list."
                    + "\n   A window will pop up confirming that you want to add all of the contacts"
                    + "\n   Click 'yes'"
                    + "\n   Your buddy list is ready to be used.";
                    JOptionPane.showMessageDialog(null, thankyou, "Migration Completed", JOptionPane.INFORMATION_MESSAGE);//Change this when defualt directory is known.
                }//end if else statement
            } //end if
            System.exit( 0 );
            if (e.getSource() == exit) {
                System.exit( 0 );
            } //end if
        } //end actionPerformed
        String[] parseDatFile(File datFile)
        throws Exception    {
            List list = new ArrayList();
            BufferedReader br = new BufferedReader(new FileReader(datFile));
            String line;
            while ((line = br.readLine()) != null) {
                line = line.trim();
                if (line.indexOf("U") != 0)
                    continue;
                int p = line.indexOf("::");
                if (p == -1)
                    continue;
                line = line.substring(p + 2).trim();
                if (line.indexOf("AOL") == 0)
                    continue;
                p = line.indexOf(",");
                if (p != -1)
                    line = line.substring(0, p);
                line = line.trim() + "@mci.com";
                if (list.indexOf(line) == -1)
                    list.add(line);
            }//end while
            br.close();
            String[] contactArray = new String[list.size()];
            list.toArray(contactArray);
            return contactArray;
        }// end String
        // setting up the XML file
        Document createXMLDocument(String[] contactArray) throws Exception {
            DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = dBF.newDocumentBuilder();
            DOMImplementation domImpl = builder.getDOMImplementation();
            Document document = domImpl.createDocument(null, "messenger", null);
            Element root = document.getDocumentElement();
            Element svcElm = document.createElement("service");
            Element clElm = document.createElement("contactlist");
            svcElm.setAttribute("name", "Microsoft RTC Instant Messaging");
            svcElm.appendChild(clElm);
            root.appendChild(svcElm);
            for (int i = 0; i < contactArray.length; i++) {
                Element conElm = document.createElement("contact");
                Text conTxt = document.createTextNode(contactArray);
    conElm.appendChild(conTxt);
    clElm.appendChild(conElm);
    }//end for
    return document;
    }// end Document
    void saveToXMLFile(Document document, File xmlFile) throws Exception {
    OutputStream os =
    new BufferedOutputStream(new FileOutputStream(xmlFile));
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");//puts information on seperate lines
    transformer.setOutputProperty(OutputKeys.METHOD, "xml");
    transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");//gives the XML file indentation
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(os);
    transformer.transform(source, result);
    os.close();
    }//end saveToXMLFile
    public static void main(String[] args) {
    Sametime st = new Sametime();
    ImageIcon picIcon = new ImageIcon(st.getClass().getResource("/images/mci.gif"));//Change when default is known!
    st.setIconImage(picIcon.getImage());
    } //end main
    private void setLookAndFeel() {
    try {
    UIManager.setLookAndFeel(
    UIManager.getSystemLookAndFeelClassName());
    SwingUtilities.updateComponentTreeUI(this);
    } catch (Exception e) {
    System.err.println("Could not use Look and Feel: " + e);
    } //end catch
    } //end void setLookAndFeel
    } //end public class Sametime

    Are there features of Java 1.4 that you specifically took advantage and are there any particular lines you are having problems with or did you just freak and post it here?
    Basically compile it under Java 1.3 and see what complains. I've done several projects that compile under 1.2, 1.3, and 1.4.

  • New Features for Java GUI

    Hello everyone!
    Can anybody tell about new features in SAP GUI for Java. I think It's emasculate now. It doesn't contain New ABAP editor, Network graphic, normal Screen Painter... I really enjoy adding themes and other stuff, but when these functionality will be added?
    Thanks.

    Hi,
      I use Java GUI from version 6.40, so i didn't know new ABAP editor for years. Once somebody shows me its features ...and I found that it is really good editor compared with previous Notepad-like frontend editor. But I have to say that customized version od Gvim used as external editor is in 90% better then new ABAP editor (the only problem is that double click on object doesn't work, but some workarounds are known for double-click on locally defined objects).
    Graphical screen painter is generally good tool, but once I cannot find any feature (sorry, I forgot which one, it happens about 6 years ago). I ask a SAP guru sitting near me. He comes, switch graphical screen painter off and click to a box in non-graphical version of screen painter. Then he told me that some features are not accessible in graphical screen painter. It was last time I used graphical version of screen painter.
    Themes? Works .... at least for me (Linux 32 bit and now Linux 64 bit too).
    So I think that Java GUI is usable (at least on Linux/Mac, I am not sure how in works under Windows) but you cannot stick on all features (and maybe you can find better working variants of it). E. g. I have no problem with new ABAP editor, it would be much better for me, if I can open external editor clicking to "Change" button in SE38 directly instead of click plus selecting external editor from menu.
    Regards,
      Pavel

Maybe you are looking for