Java code check

Hi Java Experts,
Could anyone pls chk the code given below....when i try to run this code...it comes up with many errors.....pls help
import java.awt.*;
public class scrollimage extends java.applet.Applet implements Runnable {
Image buf;
Graphics gBuf;
Dimension d;
int x=2, wd, h=0, ht, count, MaxCount=400;
int dist = 1;
int timeout = 80, pflag;
String text = "THE END! Thanks";
String text2 = "Click to Restart";
Thread scroller;
Font ft;
Image imgs[];
public void init() {
d = size();
buf = createImage( d.width,d.height);
gBuf = buf.getGraphics();
wd = size().width-2;
ht = size().height-120;
imgs= new Image[1];
imgs[0] = getImage(getCodeBase(),"car2.jpg");
setBackground(Color.white);
public void start() {
x=2; h=0;
if (scroller == null) {
scroller = new Thread(this);
scroller.start();
public void stop() {
if (scroller != null) {
scroller.stop();
scroller = null;
public void run() {
try {Thread.currentThread().sleep(5*timeout);}
catch (InterruptedException e){}
for (count=0; count <= MaxCount; ) {
try {Thread.currentThread().sleep(timeout);}
catch (InterruptedException e){}
repaint();
public void destroy() { gBuf.dispose(); }
public void update(Graphics g) { paint(g); }
public void paintApplet(Graphics g) {     
x += dist;
count++;
if (x > wd) { x = 2; }
if (count < MaxCount) {
h = (int)(ht * (1 - Math.cos(x*31.4159/wd)))/2 + 2;
g.setColor(getBackground());
g.fillRect(0,0,d.width,d.height);
g.drawImage(imgs[0],x,h,this); }
else {
ft = new Font("Helvetica",Font.BOLD,18);
g.setFont(ft);
g.setColor(Color.red);
g.drawString(text,155,80);
g.setColor(Color.cyan );
g.drawString(text2,170,120);
public void paint(Graphics g) {
paintApplet(gBuf);
g.drawImage(buf,0,0,this);
public boolean mouseDown(Event e, int x, int y)
{ scroller = new Thread(this);
scroller.start();
return true; }
}

import java.awt.*;
public class scrollimage extends java.applet.Applet implements Runnable {
    Image buf;                              
    Graphics gBuf;                          
    Dimension d;
    int x=2, wd, h=0, ht, count, MaxCount=400;
    int dist = 1;                 
    int timeout = 80, pflag;      
    String text = "THE END!  Thanks";
    String text2 = "Click to Restart";
    Thread scroller;
    Font   ft;
    Image  imgs[];
    public void init() {
        d = size();
        buf = createImage( d.width,d.height); 
        gBuf = buf.getGraphics();            
        wd = size().width-2;
        ht = size().height-120;
        imgs= new Image[1];
        imgs[0] = getImage(getCodeBase(),"car2.jpg");
        setBackground(Color.white);
    public void start() {
        x=2; h=0;
        if (scroller == null) {
            scroller = new Thread(this);
            scroller.start();
    public void stop() {
        if (scroller != null) {
            scroller.stop();
            scroller = null;
    public void run() {
          try {Thread.currentThread().sleep(5*timeout);}
            catch (InterruptedException e){}
        for (count=0; count <= MaxCount; ) {
          try {Thread.currentThread().sleep(timeout);}
            catch (InterruptedException e){}
          repaint();
    public void destroy() { gBuf.dispose(); } 
    public void update(Graphics g) { paint(g); }   
    public void paintApplet(Graphics g) {     
        x += dist;
        count++;
        if (x > wd) { x = 2; }
      if (count < MaxCount) {
        h = (int)(ht * (1 - Math.cos(x*31.4159/wd)))/2 + 2;
        g.setColor(getBackground());
        g.fillRect(0,0,d.width,d.height);
        g.drawImage(imgs[0],x,h,this); }
      else {
        ft = new Font("Helvetica",Font.BOLD,18);
        g.setFont(ft);
        g.setColor(Color.red);
        g.drawString(text,155,80);
        g.setColor(Color.cyan );
        g.drawString(text2,170,120);
    public void paint(Graphics g) {
      paintApplet(gBuf);                     
      g.drawImage(buf,0,0,this);             
    public boolean mouseDown(Event e, int x, int y)
      { scroller = new Thread(this);
            scroller.start();
        return true; }
Errors displayed:-
scrollimage.java:25: incompatible types
found : java.awt.Image
required: Image
buf = createImage( d.width,d.height);
^
scrollimage.java:26: cannot resolve symbol
symbol : method getGraphics ()
location: class Image
gBuf = buf.getGraphics();
^
scrollimage.java:31: incompatible types
found : java.awt.Image
required: Image
imgs[0] = getImage(getCodeBase(),"car2.jpg");
^
scrollimage.java:70: cannot resolve symbol
symbol : method drawImage (Image,int,int,scrollimage)
location: class java.awt.Graphics
g.drawImage(imgs[0],x,h,this); }
^
scrollimage.java:83: cannot resolve symbol
symbol : method drawImage (Image,int,int,scrollimage)
location: class java.awt.Graphics
g.drawImage(buf,0,0,this);
^
Note: scrollimage.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
5 errors

Similar Messages

  • How to check for a logic bomb in compiled java code ?

    I have couple of security requirements.
    1. How do I check for logic bomb in the compiled java code ?
    2. Is there any way to monitor memory utilized by class when running inside a constructor ?

    1. Let me see if you can define 'logic bomb', then maybe a answer can be supplied. If you simply mean malicious code, then in general you cannot. You can attempt to do the kinds of things that antivirus software does, like check for the existence of known malicious code and code patterns, but that won't work any better on Java than it does on anything else.
    2. Google java profiling. Also, for something relatively simple, read about jconsole.

  • Error while executing a custom java code from report in BI Publisher

    Hi,
    I have created a custom code added the jar in /opt/oracle/BI_Middleware/user_projects/domains/bifoundation_domain/lib and created a rtf template and added a code in that
      <?namespace:bipext=http://www.oracle.com/XSL/Transform/java/com.test.bi.CustomFunctions?>
      <?for-each:listOfNames?>
      <?bipext:helloFunction(name)?>
      <?end for-each?>
    according to the blog
    Vishal's blog: Using custom transformations in BI Publisher 10G
    I am using BI Publisher 11g and weblogic . But I am getting the below error when running the report . Please help . Its urgent.
    getting the below error from the BI Publisher desktop software
    FOProcessor setLocale: en-us
    oracle.xdo.XDOException: java.lang.reflect.InvocationTargetException
        at oracle.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1205)
        at oracle.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:276)
        at oracle.xdo.template.FOProcessor.createFO(FOProcessor.java:1973)
        at oracle.xdo.template.FOProcessor.generate(FOProcessor.java:1117)
        at RTF2PDF.runRTFto(RTF2PDF.java:659)
        at RTF2PDF.runXDO(RTF2PDF.java:452)
        at RTF2PDF.main(RTF2PDF.java:302)
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at oracle.xdo.common.xml.XSLT10gR1.invokeProcessXSL(XSLT10gR1.java:917)
        at oracle.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:609)
        at oracle.xdo.common.xml.XSLT10gR1.transform(XSLT10gR1.java:327)
        at oracle.xdo.common.xml.XSLTWrapper.transform(XSLTWrapper.java:187)
        at oracle.xdo.template.fo.util.FOUtility.generateFO(FOUtility.java:1181)
        ... 6 more
    Caused by: oracle.xdo11g.xpath.XPathException: Extension function error: Class not found 'com.test.bi.CustomFunctions'
        at oracle.xdo11g.xslt.XSLStylesheet.flushErrors(XSLStylesheet.java:1850)
        at oracle.xdo11g.xslt.XSLStylesheet.execute(XSLStylesheet.java:616)
        at oracle.xdo11g.xslt.XSLStylesheet.execute(XSLStylesheet.java:551)
        at oracle.xdo11g.xslt.XSLProcessor.processXSL(XSLProcessor.java:341)
        at oracle.xdo11g.xslt.XSLProcessor.processXSL(XSLProcessor.java:189)
        at oracle.xdo11g.xslt.XSLProcessor.processXSL(XSLProcessor.java:226)
        at oracle.xdo11g.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:122)
        ... 15 more
    and below error from GUI
    Error 
    The report cannot be rendered because of an error, please contact the administrator.
    Error Detail
    oracle.xdo.XDOException: oracle.xdo.XDOException: XSLT10gR1: Failed Secure Java Extensions check.
    Please help
    Thanks,
    Sahana

    BI Publisher

  • How to change InputField background color using Java Code

    Hi,
    In my application use will enter some set of Cost Centers in a table and submits request.
    In return i will get a list of invalid cost centers which i need to display in a table with input field
    In that table all cost centers will displayed, but invalid cost centers should be highlighted or background color should some other color. like red or yellow.
    Is it possible using java code to change a input field color.
    Please help me.
    Thanks

    Hi,
        declare a error message in message pool and declare a method say "checkCostCenters " and in this method, u can check whether it is a valid cost center .. if it is invalid cost center , then throw the erro message using the below code :
    wdComponentAPI.getMessageManager().reportContextAttributeMessage(
                        inputfieldattibutePointer, IMessageProgramPlanComp.ur error message,
                        new Object[] );
    for getting pointer and label use the below code:
    IWDAttributePointer inputfieldPointer = URNODEELEMENTElement
                        .getAttributePointer(URNODEELEMENT.ATTRIBUTENAME);
              String inputfieldLabel = wdContext.nodeURVALUENODE.getNodeInfo()
                        .getAttribute(URNODELEMENT.ATTRIBUTE).getSimpleType()
                        .getFieldLabel();
    hope it helps..
    Thanks and Regards

  • Can anybody help on sending mail through Java Code

    I am trying to send the mail using the java code and I am unable to do it. My code is
    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.text.*;
    public class EmailExample {
    public static void main(String[] args)
    Socket smtpSocket;
    DataOutputStream os;
    BufferedReader is;
    Date dDate = new Date();
    DateFormat dFormat = DateFormat.getDateInstance(DateFormat.FULL,Locale.US);
    try
    smtpSocket = new Socket("www.gmail.com",80);
    os = new DataOutputStream(smtpSocket.getOutputStream());
    is = new BufferedReader(new InputStreamReader(smtpSocket.getInputStream()));
    System.out.println("Hi How is this?");
    os.writeBytes("HELLO\r\n");
    // You will add the email address that the server
    // you are using know you as.
    os.writeBytes("MAIL From: <[email protected]>\r\n");
    // Who the email is going to.
    os.writeBytes("RCPT To: <[email protected]>\r\n");
    //IF you want to send a CC then you will have to add this
    //os.writeBytes("RCPT Cc: <[email protected]>\r\n");
    // Now we are ready to add the message and the
    // header of the email to be sent out.
    os.writeBytes("DATA\r\n");
    os.writeBytes("X-Mailer: Via Java\r\n");
    os.writeBytes("DATE: " + dFormat.format(dDate) + "\r\n");
    System.out.println("DATE: " + dFormat.format(dDate) + "\r\n");
    os.writeBytes("From: Me <[email protected]>\r\n");
    os.writeBytes("To: YOU <[email protected]>\r\n");
    //Again if you want to send a CC then add this.
    //os.writeBytes("Cc: CCDUDE <[email protected]>\r\n");
    //Here you can now add a BCC to the message as well
    //os.writeBytes("RCPT Bcc: BCCDude<[email protected]>\r\n");
    String sMessage = "Your subjectline here";
    os.writeBytes("Subject: Your subjectline here\r\n");
    os.writeBytes(sMessage + "\r\n");
    os.writeBytes("\r\n.\r\n");
    os.writeBytes("QUIT\r\n");
    // Now send the email off and check the server reply.
    // Was an OK is reached you are complete.
    String responseline;
    while((responseline = is.readLine())!=null)
    {   System.out.println(responseline);
    if(responseline.indexOf("Ok") != -1)
    break;
    } catch (IOException e) {
    e.printStackTrace();
    It is compiling and runnung properly. Please Help me on this.
    Thanks.
    Satya.

    You're mishandling the responses. You terminate if you don't get an "Ok" string, but that's not how success is defined - you should get a 200 code back, typically with an "OK" (not caps) message.
    It doesn't help that you're ignoring all of the server output after each command, so you never find out if anything goes wrong.
    You're also reinventing a wheel. The JavaMail API exists for this: http://java.sun.com/products/javamail/

  • Using a Variable from web-inf/web.xml in java code?

    I would like to create a read-only variable with a value in the /web-inf/web.xml file and then access that value within a java service method within the Application Module.
    Where / how do I read the value from the web.xml file and make it accessible within my java code?
    thanks

    Hi,
    you can define context parameters in web.xml that you can access from Java in the web application
    The following is a JSF examle that checks a context parameter in a PhaseListener, where the string is stored ina Java constant (could be "myParam")
    ExternalContext exctx = FacesContext.getCurrentInstance().getExternalContext();
    useSessionPageCache = exctx.getInitParameter(Constants.USE_PAGE_CACHE) == null ? false :
    (exctx.getInitParameter(Constants.USE_PAGE_CACHE)).equalsIgnoreCase("TRUE") ? true : false;
    From here you can call a method on the AM to set the value or look for another option.
    Frank

  • Error while running compiled java code

    Hi
    I have an evaluation license of the JDeveloper2.0 installed on my WindowsNT 4.0 workstation.
    I seem to have a problem running my compiled jave code. After compiling the source code(.java file) when I try to run the same I get a message saying
    "<FileName> not found in outpath classpath or sourcepath ".
    What does this mean and how can I rectify it?
    Regards
    Sree
    null

    Your classpath tells Java run time where to look for the class files it needs. In JDeveloper the class path is set in your project properties. Select Project->Properties and check that the source and output paths correspond to your myprojects and myclasses directories.

  • Error while sending Email through Java Code in OIM

    Hi All,
    I have created a java code using tcEmailNotificationUtil, and integrated the same with the adapter.
    I am triggering this adapter when an approval process gets completed.
    As soon as the approval process gets completed my email task is triggering but the task is getting rejected.
    I have checked my system configuration for mail server settings.Everything seems working fine.
    Can you please help me in this issue how to debug?
    Thanks in advance.

    Hi,
    Here is my log file:
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/insertTaskHistory left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/run entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/execute entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/initialize entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getAttribute entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getAttribute left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getUtility entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getUtility left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.ACCOUNTMANAGEMENT] - Class/Method: tcUtilityFactory/getRemoteUtility - Data: moUtil - Value: Thor.API.Operations.tcAuditOperationsClient
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/initialize left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/processAllByIdentifier entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,100,[XELLERATE.DATABASE] - select A.* from (select aud_jms_key, aud_class, identifier from aud_jms order by aud_jms_key) A where rownum <= ?
    INFO,25 Apr 2011 10:40:00,101,[XELLERATE.PERFORMANCE] - Query: DB: 1, LOAD: 0, TOTAL: 1
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/execute left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/run left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isSuccess entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isSuccess left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: SchedulerTaskLocater /removeLocalTask entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: SchedulerTaskLocater /removeLocalTask left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateStatusToInactive entered.
    DEBUG,25 Apr 2011 10:40:00,104,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateStatusToInactive left.
    DEBUG,25 Apr 2011 10:40:00,104,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateTaskHistory entered.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateTaskHistory left.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Clearing Security Associations with thread executing Scheduled task
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/run left.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/execute left.
    and I just wanted to ensure that my coding part is also fine.
    Posting the code even:
    tcDataProvider ioDatabase = new tcDataBaseClient();
    tcEmailNotificationUtil sendMail = new tcEmailNotificationUtil(ioDatabase);
    sendMail.setBody("Sample Message");
    sendMail.setSubject("subject");
    sendMail.setFromAddress("fromemailaddress");
    sendMail.sendEmail("recepient");
    Thanks in Advance.

  • Java Code in a text file

    Hi,
    I need an information if whether anything like this can be done in java or not !!
    The requirement is to place the jave code statements into a text file and dynamically execute these statements which have been placed in the file. for eg: if a text file "test.txt" contains a statement
    System.out.println("Hello world"); without the class being defined or the main method being defined. I need to execute this statement and print out hello world on the console.
    is this possible ???
    I would be using JDK 1.2 or 1.3 for this but certainly not 1.4.x and above
    please do let me know if this problem can be tackled in anyway !!
    Thanks in advance !

    I'd suggest first checking to see if the code in question would also be valid code in an interpreted language like Javascript, Groovy, or BeanShell.
    If it is, then use an interpreter for the appropriate language, an interpreter written in Java and which you can plug into the Java program you're using.
    Otherwise, I suppose you could wrap a class and method around the code, and compile and run that.

  • Should I do this with Java Code or Stored Procs ? (for best performance)

    Hi All,
    I need to decide where should I implement my business logic, in Java code or Stored procs.
    Here is the requirement :
    - One Order has 70 products (Order_Table )
    - Can be duplicate products, so I have to do summarize / grouping by product
    - For every product, I have to check, if it is entitled for a Bonus product, then I have to Insert one to Bonus_Table.
    - This is done when/after the transaction is SAVED (COMMIT)
    The question is, which one has better PERFORMANCE :
    (1) Create a rowsetIterator on the Order details (70 products) and call a stored procedure to do the logic for every single product (so that the Insert to Bonus_Table done in stored proc). means the stored proc will be called 70 times.
    OR
    (2) After the transaction is COMMITted, call the stored procs ONCE to do the logic for all the products at once.
    OR
    (3) I do all the logic with Java Code within ADF
    Given the requirement above, which approach is most efficient / best performance ?
    Thank you very much,
    xtanto

    Problem with this is that you ask 100 people and you probably get 100 different answers. ;o)
    Many would say that you push as much business logic into the database with your data; others might say you only put data in your database and your business logic is kept on the application server.
    In reality your would probably have a mix of both and your decision would probably be influenced by your own background ...
    Can't be more precise than that.
    Grant

  • Logging Not Working in Java Code

    Hi everyone,
    I'm looking into the Java code for the Portal app, and I'm trying to do some debugging as to what's going on.  I see a lot of the Adobe classes use the log4j Logger to output general logging information as well as errors, but there never seems to be any output in the log files.  The files I'm checking for activity are:
    Adobe LiveCycle ES2\jboss\server\lc_turnkey\log\server.log
    Adobe LiveCycle ES2\jboss\bin\correspondencemanagement.log
    When I build and deploy the application onto the LC server, just before my application starts I get the following line in the server.log:
    2011-04-29 14:30:49,055 INFO  [STDOUT] **** No servlet context set in ServletLogTarget - logging disabled.
    followed by a message saying that my application has started.  The line above happens everytime I re-deploy the application (without actually running the app), right before it starts, so I'm assuming that it is directly related to my application.
    The only 'com.adobe' related logging lines that happen in the correspondencemanagement.log file are written when I physically run the app, and I get the following line:
    2011-04-29 14:31:34,298 69729 INFO  [com.adobe.dct.service.impl.DataDictionaryRegistryServiceImpl] Fetching Complete Data Dictionary object graph.
    Looking into the code for the com.adobe.dct.service.impl.DataDictionaryRegistryServiceImpl class, I see it uses a completely different logging system (ie not log4j).
    *sigh*
    I've changed the services-config.xml file and tried setting the logging target to both flex.messaging.log.ServletLogTarget and flex.messaging.log.ConsoleTarget, but neither seem to make a difference.
    I must be missing some kind of configuration to get the logging to work correctly, but Google has been little help as well.
    Hopefully someone has crossed this issue before, and has a solution?  Any help / pointers / advice etc welcome and appreciated!!!
    Thanks,
    Kristian

    Thanks for the reply Saket.
    It turns out that the logging was working correctly all along.  The messages I could not find were all related to bootstrap code.  I was assuming that the bootstrapper would run each time the application was deployed, or at the very least each time the server was started.  It turns out that you manually need to run the bootstrapper.  So I was looking for log lines that would never appear by themselves.  Once I manually ran the bootstrap process, the log lines ran as expected.
    Cheers,
    K.

  • How to Configure the Datasource In JNDI and access it through Java Code

    I have declared under web.xml
    <resource-ref>
          <res-ref-name>MSDataSource</res-ref-name>
          <res-type>javax.sql.DataSource</res-type>
          <res-auth>Container</res-auth>
          <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    Under Jrun-resource.xml
    <data-source>
                <dbname>xxxxxxx</dbname>
                <driver>macromedia.jdbc.sqlserver.SQLServerDriver</driver>
                <url>jdbc:macromedia:sqlserver://xxx.xxx.xx.xx:1433;databaseName=xxxxxxx</url>
                <username>xxxxxxxx</username>
                <password>xxxxxxxxx</password>
                <encrypted>false</encrypted>
                <encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
                <native-results>true</native-results>
                <remove-on-exceptions>true</remove-on-exceptions>
                <pool-statements>false</pool-statements>
                <initial-connections>1</initial-connections>
                <connection-timeout>1200</connection-timeout>
                <transaction-timeout>20</transaction-timeout>
                <cache-enabled>false</cache-enabled>
                <cache-size>5</cache-size>
                <cache-refresh-interval>30</cache-refresh-interval>
                <jndi-name>MSDataSource</jndi-name>
                <poolname>Pool</poolname>
                <minimum-size>0</minimum-size>
                <maximum-size>2147483647</maximum-size>
                <user-timeout>20</user-timeout>
                <skimmer-frequency>420</skimmer-frequency>
                <shrink-by>5</shrink-by>
                <maximum-soft>true</maximum-soft>
                <debugging>false</debugging>
                <disable-pooling>false</disable-pooling>
                <isolation-level>READ_UNCOMMITTED</isolation-level>
                <description/>
         </data-source>
    Under jrun-web.xml
    <resource-ref>
          <res-ref-name>MSDataSource</res-ref-name>
          <jndi-name>MSDataSource</jndi-name>
    </resource-ref>  
    Java Code
    String dsndb="java:comp/env/MSDataSource";
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,"jrun.naming.JRunContextFactory");
    p.put(Context.PROVIDER_URL, "localhost:2932");
    InitialContext context=new InitialContext(p);
    System.out.println(context.getEnvironment());
    DataSource ds=(DataSource)context.lookup(dsndb);
    ds.getConnection();
    System.out.println(ds.getConnection().toString());
    Error is
    {java.naming.provider.url=localhost:2932, java.naming.factory.initial=jrun.naming.JRunContextFactory}
    Exception in thread "main" javax.naming.NameNotFoundException: No such binding: MSDataSource
        at jrun.naming.ContextManager.getBinding(ContextManager.java:680)
        at jrun.naming.ContextManager.getBinding(ContextManager.java:686)
        at jrun.naming.ContextManager.getObject(ContextManager.java:690)
        at jrun.naming.ContextManager.lookup(ContextManager.java:463)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:501)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:644)
        at jrun.naming.JRunNamingContext.lookup(JRunNamingContext.java:470)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at Controller.DBManager.getConnection(DBManager.java:29)
        at Controller.DBManager.main(DBManager.java:42)
    Please help me .
    Thanks in advance

    Also, try to log the username/password in your authenticator, just to be sure that credentials changeGood piece of advice, michael. Worth of it. When I changed the credentials manually, it worked correctly,but from the application, when I logout from 'a', 'a' and log in to 'b', 'b', I got a valuable information.
    I tried debugging like given below for checking from the application.
    class MyAuthenticator extends Authenticator {
        protected PasswordAuthentication getPasswordAuthentication() {
             System.out.println("userrrrrrrrr"+UtilsHTTPS.username);
             System.out.println("pwdddddddddd"+UtilsHTTPS.password);
      .........................................The information I got while debugging from the application was, the username and password does not get printed. It implies that, Authenticator.setDefault(new MyAuthenticator()); does not work as desired ie; even on calling new MyAuthenticator(), it does not get inside the MyAuthenticator class.
    Why does this happen? What is the solution for this?

  • Not able to checkout Files using Java Code and SAP BAPI  from DMSServer

    Hi
    Able to download / checkout the files using T-Code SE37 (BAPI_DOCUMENT_CHECKOUTVIEW2).
    But when same RFC is executed from Java, it alsways says -
    Message ::::::::Document LGL/10000000003/000/00 does not exist
    My inputs in Java Code is as below -
    import java.io.*;
    import java.util.*;
    import com.sap.mw.jco.*;
    //CREATED ON - 10-APRIL-2010.
    public class BapiDocCheckOutview {
         public static void main(String args[]){
              try{
                   if(mConnection!=null){
    JCO.Repository repository=new JCO.Repository("AraSoft",mConnection);
    JCO.setMiddlewareProperty("jco.middleware.allow_start_of_programs", "SAPFTPA");
    JCO.Function function=repository.getFunctionTemplate("BAPI_DOCUMENT_CHECKOUTVIEW2").getFunction();
                        //End of get function.
                     System.out.println("Before execution1");
                     if(function !=null){
                   JCO.Field DOCUMENTTYPE = function.getImportParameterList().getField("DOCUMENTTYPE");
                    DOCUMENTTYPE.setValue("LGL");
                    JCO.Field DOCUMENTNUMBER = function.getImportParameterList().getField("DOCUMENTNUMBER");
                    DOCUMENTNUMBER.setValue("10000000003");
                    JCO.Field DOCUMENTPART = function.getImportParameterList().getField("DOCUMENTPART");
                    DOCUMENTPART.setValue("000");
                    JCO.Field DOCUMENTVERSION = function.getImportParameterList().getField("DOCUMENTVERSION");
                    DOCUMENTVERSION.setValue("00");
                    JCO.Field GETSTRUCTURE = function.getImportParameterList().getField("GETSTRUCTURE");
                    GETSTRUCTURE.setValue("1");
    JCO.Field GETCOMPONENTS = function.getImportParameterList().getField("GETCOMPONENTS");
                 GETCOMPONENTS.setValue("X");
    JCO.Field ORIGINALPATH = function.getImportParameterList().getField("ORIGINALPATH");
                  ORIGINALPATH.setValue("C:
    TEMP
    DMS_");
    JCO.Field GETHEADER = function.getImportParameterList().getField("GETHEADER");
                          GETHEADER.setValue("X");
    JCO.Field PF_FTP_DEST=function.getImportParameterList().getField("PF_FTP_DEST");
              PF_FTP_DEST.setValue("SAPFTPA");
    //JCO.Field PF_HTTP_DEST=function.getImportParameterList().getField("PF_HTTP_DEST");
         //PF_HTTP_DEST.setValue("SAPHTTPA");
                          System.out.println("Here Setting Values Inside Structure ::DOCUMENTFILE");
    JCO.Structure DOCUMENTFILE=function.getImportParameterList().getStructure("DOCUMENTFILE");
    DOCUMENTFILE.setValue("1","ORIGINALTYPE");
    DOCUMENTFILE.setValue("WWI","WSAPPLICATION");
    DOCUMENTFILE.setValue("ZHCL_CS","STORAGECATEGORY");
    DOCUMENTFILE.setValue("E0DF7893E2BD5DF19C07001517B4A299","APPLICATION_ID");
    DOCUMENTFILE.setValue("E0DF7893E2BD5FF19C07001517B4A299","FILE_ID");
    DOCUMENTFILE.setValue("X","CHECKEDIN");
    DOCUMENTFILE.setValue("X","ACTIVE_VERSION");
                            //DOCUMENTFILE.setValue("LGL","DOCUMENTTYPE");
                            //DOCUMENTFILE.setValue("10000000003","DOCUMENTNUMBER");
                            //DOCUMENTFILE.setValue("000","DOCUMENTPART");
                            //DOCUMENTFILE.setValue("00","DOCUMENTVERSION");
                          //JCO.Field GETCOMPONENTS = function.getImportParameterList().getField("GETCOMPONENTS");
                          //GETCOMPONENTS.setValue("X");
                          //JCO.Field GETHEADER = function.getImportParameterList().getField("GETHEADER");
                          //GETHEADER.setValue("X");
                        mConnection.execute(function);
    If anyone have an Idea on what I have missed out...
    Please do advice me.
    Thanks
    Prashant

    Hi
    To update in the initial requirement, I have added (prefixed, zeroes) in Document No., doing that, now the  application is able to find the document, but not able to transfer the same from DMS Server to my local Machine, always giving the following error -
    Type ::::::::E
    Message ::::::::File d:\dms\z_IPI_PRASHANT01.doc cannot be created
    Please let me know, if some services needed to checked in SAP System or some more information to be provided in RFC.
    Thanks
    Prashant
    Dear Experts
    Any advice on this. Still not able to download the documents from DMS Server.
    I have also added few more code in my Java program -
         private int use_sapgui;
         public void setSapGui(int use_sapgui){
              use_sapgui = 2;
    PLease help !!
    Regards
    Edited by: Prashantroy on Sep 26, 2011 12:49 PM
    Hi,
    Further to my earlier Mail, while checking the Trace suing SM59 in ECC System I got  the following Error -
    Trace file opened at 20111010 142232 India Standard Time, SAP-REL 701,0,134
    ======> cannot open SAPGUI
    ABAP Programm: SAPLSYSE (Transaction: )
    User: IPI_PRASHANT (Client: 220)
    Destination: SAPFTP (handle: 3, , )
    SERVER> RFC Server Session (handle: 1, 43220900, {5D1DF3E0-ACBD-F11F-8EA0-00A0D1
    SERVER> Caller host:
    SERVER> Caller transaction code:  (Caller Program: java)
    SERVER> Called function module: RFC_START_PROGRAM
    Error RFCIO_ERROR_SYSERROR in abrfcpic.c : 1742
    FUNCTION: 'exec_sapgui'
    cannot open SAPGUI
    PROG =sapftp erpdev sapgw00 43232164 IDX=4
    Can someone help me in getting this sorted out.
    Thanks N Regards
    Edited by: Prashantroy on Oct 10, 2011 2:32 PM

  • How do you turn java code into an .exe or etc...

    I can't seem to figure out how to turn my java code into an executable in windows so that it runs by itself without a comipler, can someone help? (without using visual J++).

    I can't seem to figure out how to turn my java code
    into an executable in windows so that it runs by
    itself without a comipler, can someone help? (without
    using visual J++).I saw a tutorial on that, you might want to check it out.
    http://developer.java.sun.com/developer/onlineTraining/new2java/divelog/?frontpage-headlinesfeatures

  • Monitor message in adapter engine through java code

    Hi all,
    I need to write a java code to monitor message using message ID in adapter engine.
    Is it possible to write such a code?
    If yes, then please provide information regarding to that.

    Hi,
    Check these threads
    Retrieving a message id
    Re: How to extract XI-header fields from XI-message in JAVA?
    Thanks!

Maybe you are looking for

  • VO Extension not working in R12

    Hi all i have to extend a subtablayout region to add new column ; for that i extended VO which is EO based. I have done all necessary steps but my problem is this error: Message not found. Application: FND, Message Name: FND_VIEWOBJECT_NOT_FOUND. Tok

  • OS Downgrading issues Windows 8 to 7

    I down graded my Toshiba Satellite l855d-s5117, because there was some software that I use that wasn't compatible with 8. I had a couple of issues when I switch over to 7 though. 1. I can't find the driver for the Universal Serial Bus Controller. Fro

  • Copying an alpha channel from one comp to another?

    I've created a green screen key using Primatte in one comp, and I want to use that same key in another comp, but where the background has since been replaced and rendered out with an effect I want to keep on the foreground subject. I bet it's somethi

  • Want to append time stamp to file name in log4j property

    Hi I want to append the timestamp to name of log file. here i am attaching my sample log4j.property file plase heple me for correct syntax log4j.logger.bar=DEBUG, dest1 log4j.appender.dest1=org.apache.log4j.DailyRollingFileAppender log4j.appender.des

  • Flex - data merge to PDF document

    We have a requirment to get the state form from the web site, later the created application in flex will be a data entry for the user to enter data. After complitation of data entry and submission to database, data should merge to the given pdf docum