Reposting ! string concatanation not working in java

hi I am using the following code to construct a string and i see that it seems that the correct string is made but the application does not run
if i just cut n paste the same string into command prompt it works fine . please advise :
also note iam costructing string in two way , but using stringbuffer and by using , but both ways dont work.
If the parameter is just one word for example say "Testing" then the shell command works fine which tells me that the string concatanation is not working or embedding some special chars?
public static void main(String args[]) {
String s = null;
// system command to run
String quotes="\"";
String parameter = quotes args[0] quotes;
String cmd = "awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s " parameter;
System.out.println(cmd);
File workDir = new File("/opt/CA/SharedComponents/ccs/atech/services/bin");
StringBuffer sb = new StringBuffer();
sb.append("awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s ");
sb.append("\"");
sb.append(args[0]);
sb.append("\"");
String str2 = sb.toString();
System.out.println(str2);
try {
Process p = Runtime.getRuntime().exec(cmd, null, workDir);
========================================== below is the run log ============================================
awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
usage: /opt/CA/SharedComponents/ccs/atech/services/bin/awtrap [-v 1 | 2c | 3] [-i] [-r retries] [-f from_addr | from_host]
[-h dest_addr | dest_host] [-p port] [-t timeout ] [-d logLevel]
[-c community] enterprise type [subtype] [oid oidtype value]
================================= now if I just cut n paste the string on command prompt it runs fine =====================
Pt$ awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
Pt$

I am putting the code in code tags and in preview it shows up perfect, can you see it now ?
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
public class RunSystemCommand {
public static void main(String args[]) {
String s = null;
// system command to run
String quotes="\"";
String parameter = quotes + args[0] + quotes;
String cmd = "awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2  6 4 1.3.6.1.4.1.791.2.9.2 -s " + parameter;
System.out.println(cmd);
File workDir = new File("/opt/CA/SharedComponents/ccs/atech/services/bin");
StringBuffer sb = new StringBuffer();
sb.append("awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2  6 4 1.3.6.1.4.1.791.2.9.2 -s ");
sb.append("\"");
sb.append(args[0]);
sb.append("\"");
String str2 = sb.toString();
System.out.println(str2);
try {
Process p = Runtime.getRuntime().exec(cmd, null, workDir);
int i = p.waitFor();
if (i == 0){
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
// read the output from the command
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
else {
BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
while ((s = stdErr.readLine()) != null) {
System.out.println(s);
catch (Exception e) {
System.out.println(e);
{code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • String parsing not working in Java

    hi I am using the following code to construct a string and i see that it seems that the correct string is made but the application does not run
    if i just cut n paste the same string into command prompt it works fine . please advise :
    also note iam costructing string in two way , but using stringbuffer and by using + , but both ways dont work.
    public static void main(String args[]) {
    String s = null;
    // system command to run
    String quotes="\"";
    String parameter = quotes + args[0] + quotes;
    String cmd = "awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s " + parameter;
    System.out.println(cmd);
    File workDir = new File("/opt/CA/SharedComponents/ccs/atech/services/bin");
    StringBuffer sb = new StringBuffer();
    sb.append("awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s ");
    sb.append("\"");
    sb.append(args[0]);
    sb.append("\"");
    String str2 = sb.toString();
    System.out.println(str2);
    try {
    Process p = Runtime.getRuntime().exec(cmd, null, workDir);
    ========================================== below is the run log ============================================
    awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
    awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
    usage: /opt/CA/SharedComponents/ccs/atech/services/bin/awtrap [-v 1 | 2c | 3] [-i] [-r retries] [-f from_addr | from_host]
    [-h dest_addr | dest_host] [-p port] [-t timeout ] [-d logLevel]
    [-c community] enterprise type [subtype] [oid oidtype value]
    ================================= now if I just cut n paste the string on command prompt it runs fine =====================
    Pt$ awtrap -f 10.200.16.17 -h 10.100.10.112 -p 162 -c fdot 1.3.6.1.4.1.791.2.9.2 6 4 1.3.6.1.4.1.791.2.9.2 -s "testing 2"
    Pt$

    sahmad43 wrote:
    Saber did you take a look at my code? I am building array using two methods , and i dont wont to try the third for no reason,You are building a string not an array. My experience is that the array approach generally has less problems than the single string approach and is easier to debug.
    please read my post I am asking the question clearly dont want to repeat it here again.I spent some time with your OP making sure I understood your problem - you should read my post again. I'm am showing you an alternative to the single string approach that I have found very successful. Now you can just ignore my advice, which is based on considerable experience, and continue on in your blinkered way. I don't have the problem so I don't care
    >
    thanksBye

  • Externalize metadata strings does not work

    Hi All,
    We have installed OBIEE 11.1.1.6 with OBIApps 7.9.6.3 and we are trying to apply the spanish localization .
    We follow the steps mentioned here:
    http://docs.oracle.com/cd/E20490_01/bia.7963/e19038/anyinstadmconfiglocalize.htm#i1039838
    but "Externalize metadata strings" is not working properly.
    We did the following:
    - run the import metadata command succesfully (W_LOCALIZED_STRING_G table has the correct data).
    - bounce the services
    - Configure and test the "Externalized Metadata Strings" connection pool
    but the translations does not appears.
    We noted that there is a difference between our RPD and the steps in the guide:
    The guide says:
    +"To externalize metadata strings in the Oracle Business Intelligence repository+
    +1.Stop the Oracle BI Server.+
    +2.Using the Oracle BI Administration Tool in offline mode, open OracleBIAnalyticsApps.rpd.+
    +3.Select the entire Presentation layer and right-click the mouse to display the menu.+
    +*From the pop-up menu, select Externalize Display Names. (A check mark appears next to this option the next time you right-click on the Presentation layer.)*+
    +Unselect the Presentation layer."+
    But in the pop-up menu you can not mark "Externalize Display Names" because you have a sub-menu there: "Generate Custom Names, Disable Externalization and Clear All Externalization Stings"
    Is there some step we are missing?
    Any help will be appreciated
    Thank!

    Problem resolved

  • Applets not working with Java 1.7.0_51 in MII 14.0 SP4 Patch 5

    Hi,
    I'm currently evaluating the migration of our MII 12.0 developments to MII 14.
    But I'm running in several issues just trying to use simple things like a SQL query template with an iGrid Display template in test mode.
    Used versions are: MII 14.0 SP4 Patch 5 and on client side the latest Mozilla Firefox with Java 1.7.0_51
    At first I always get a java security warning when the applet is being loaded about unsigned applications.
    At second the applet itself is not running. It always shows "No data available" and the java console shows the following errors (iResult is the id of the applet):
    iResult [ERROR] - Couldn't set query template: No Query Defined
    iResult [ERROR] - Couldn't set display template: null
    iResult [ERROR] - Couldn't set display template: null
    Is this perhaps a general problem, that the MII applets are not working with Java 1.7.x versions?
    If I call the same MII page from a client with Java 1.6.x it is working without errors.
    Do you have some suggestions for me?
    Regards Timo

    please clear your JAVA Cache. that should solve the JRE issue. thanks

  • BAPI not working in Java Webdynpro

    Hi,
    My BAPI from SAP is working in Netweaver perfectly, but when I call the same with the equal parameters in Java webdynpro, no results.
    I'm using following function: 'CVAPI_DOC_VIEW'.
    Any idea why the BAPI is not working in Java Webdynpro?
    Regards,
    Tim

    Hi Tim,
    AFAIK 'CVAPI_DOC_VIEW'  will work only in standard SAP Dynpro. Inside Webdynpro it is forbidden to save files in the background and using GUI class with execute, so you cannot use that Standard FM.
    Check this thread .
    Thanks
    Katrice

  • Dynamic configuration not working in Java mapping

    Hi All,
    I have a scenario where i  am using java mapping. In this i am doing following
    1)Read file name from input message header
    2)set file name in output message Header
    3) set Directory name in output message Header
    i  have used following code .. but iit is not working... when i test end  to end...  in reciver communication channel it is failing stating " message failed as "Directory is not set in Header. Also i checked in SXMB_MONI  "dynamic configuration".It is not showing Directory.
    this is code.
    public void transform(TransformationInput transformationInput,TransformationOutput transformationOutput)
                   throws StreamTransformationException {
                   private Map para;
                   String Directory ;
                   String  inputFileName;
                   String var1 = "ABC";
                   para = transformationInput.getInputHeader().getAll();
                   DynamicConfiguration conf = (DynamicConfiguration) para
                             .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
                   DynamicConfigurationKey keyFileName1 = DynamicConfigurationKey
                   .create("http://sap.com/xi/XI/System/File", "FileName");
                         inputFileName = conf.get(keyFileName1);
                   DynamicConfigurationKey keyFilename = DynamicConfigurationKey
                             .create("http://sap.com/xi/XI/System/File", "FileName");
                   DynamicConfigurationKey keyDirecory = DynamicConfigurationKey
                             .create("http://sap.com/xi/XI/System/File", "Directory");
                   Directory = "tmp/"+var1;
                   conf.put(keyFilename,inputFileName);
                   conf.put(keyDirecory, Directory);
    I am in PI 7.1 ,   and in eclipse its showing warning that Para is not used.
    Can anyone show some lights.
    Also is there any way to debug this?? like is there any function by which i can write the trace for each step to see those in MONI.

    Method name:   public void createDirectory(Resultlist result, Container container)throws StreamTransformationException
    //Use Simple UDF and do the following lines
    String Directory ;
    String  inputFileName;
    String var1 = "ABC";
    DynamicConfiguration conf = container
        .getTransformationParameters()
        .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
      DynamicConfigurationKey keyFileName1 = DynamicConfigurationKey
                   .create("http://sap.com/xi/XI/System/File", "FileName");
      inputFileName = conf.get(keyFileName1);
    DynamicConfigurationKey keyFilename = DynamicConfigurationKey
                   .create("http://sap.com/xi/XI/System/File", "FileName");
    DynamicConfigurationKey keyDirecory = DynamicConfigurationKey
                   .create("http://sap.com/xi/XI/System/File", "Directory");
    Directory = "tmp/"+var1;
    conf.put(keyFilename,inputFileName);
    conf.put(keyDirecory, Directory);
    and remove these 3 lines
    //private Map para;
    //para = transformationInput.getInputHeader().getAll();
    //DynamicConfiguration conf = (DynamicConfiguration) para.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION
    >>I am in PI 7.1 , and in eclipse its showing warning that Para is not used.Can anyone show some lights.
    You can simply remove declaring Map Para line... The eclipse gives warning because you dont assign values for it and you are trying to use...
    For using the same input file name in output side, you dont need coding ... you need only for the directory...
    Enable ASMA attributes in the channel.
    Edited by: Baskar Gopal on Feb 24, 2011 10:58 AM

  • Why windows command prompt is not working with java

    I installed java 1.6 to my computer (Laptop) and it is perfectly working with Netbeans and Eclipse
    but not working with windows xp xommand prompt
    It compiles the code but when it is going to run it throw the following exception
    Exception in thread "main" java.lang.UnsupportedClassVersionError: Example (Unsupported major.minor version 50.0)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)I've reinstalled java 1.6, but the output is same
    Please help me to get it correct
    Thank you

    E:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracl
    e\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Progr
    am Files\Microsoft SQL Server\90\Tools\binn\;C:\OrCAD\OrCAD_10.0\tools\pcb\bin;C
    :\OrCAD\OrCAD_10.0\tools\specctra\bin;C:\OrCAD\OrCAD_10.0\tools\bin;C:\OrCAD\OrC
    AD_10.0\tools\PSpice\Library;C:\OrCAD\OrCAD_10.0\tools\fet\bin;C:\OrCAD\OrCAD_10
    .0\tools\jre\bin;C:\OrCAD\OrCAD_10.0\tools\Capture;C:\Program Files\QuickTime\QT
    System\;C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Microsoft Visual
    Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev9
    8\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Mic
    rosoft Visual Studio\VC98\bin;

  • {@inheritDoc} not working for Java Classes

    Hello,
    i am using {@inheritDoc} for inherting super class's JavaDoc for a perticular function..
    It is working, if super class is my own class. i am able to see all JavaDoc in child class.
    But when i use {@inheritDoc} for extending JavaDoc of java class it is not working.
    i.e. if i am writing {@inheritDoc} in public void actionPerformed(ActionEvent e) method..
    It wont show any javadoc..
    How to add it? Do i need to give source of java classes too???
    And if it is Yes, then where to specifiy. and where to find source of Java classes, do they come with JDK? or NetBeans?? (If yes then where it is in JDK or Netbeans???)
    Thanks,
    Nachiket.

    Yes, you need to have the Java source, with the -sourcepath option, as described here:
    Inheriting Comments from J2SE - Your code can also automatically inherit comments from interfaces and classes in the J2SE. You can do this by unzipping the src.zip file that ships with the SDK (it does not contain all source files, however), and add its path to -sourcepath. When javadoc runs on your code, it will load the doc comments from those source files as needed. For example, if a class in your code implements java.lang.Comparable, the compareTo(Object) method you implement will inherit the doc comment from java.lang.Comparable.
    http://java.sun.com/j2se/javadoc/faq/#incrementalbuild
    If you want the full Java source get it from here:
    http://www.sun.com/software/communitysource/j2se/java2/index.xml
    http://java.sun.com/j2se/javadoc/faq/#sourcecode
    -Doug

  • Stopsap is not working in Java ystem

    Hi All,
    We have a Java system connected to XI. stopsap command is not working when I try to shutdown the java system. I have to kill all the processes to stop the Java. The error that I am getting is the following. I used <SID>adm user to stop the Java system. We need to fix this. Please help ASAP.
    stopping the SAP instance J00
    Shutdown-Log is written to /home/JP2adm/stopsap_J00.log
    /usr/sap/JP2/J00/exe/sapcontrol -prot NI_HTTP -nr 00 -function Stop
    stop of Instance failed
    See /home/JP2adm/stopsap_J00.log for details
    Trace of system startup/check of SAP System JP2 on Mon Feb  7 16:54:02 CST 2011
    Called command: /usr/sap/JP2/SYS/exe/uc/rs6000_64/stopsap stop
    stopping the SAP instance J00
    /usr/sap/JP2/J00/exe/sapcontrol -prot NI_HTTP -nr 00 -function Stop
    07.02.2011 16:54:03
    Stop
    FAIL: HTTP error, HTTP/1.1 401 Unauthorized
    stop of Instance failed
    Thanks,
    Kavitha.
    Edited by: Kavitha Rajan on Feb 9, 2011 5:26 PM

    Thank you Sarbjeet. Your answer is very helpful.
    Thanks again,
    Kavitha Rajan.

  • J2EE_ADMIN not working in Java Side

    Hi All,
    The J2ee_admin Id is not working on the Java side, but is working on the ABAP Side. I changed the password of SAPJSF, is it bcoz of that? If yes, pls suggest what can be done.
    Regards,
    Divya

    Hi Divya,
    You can Activate the Emergency User (find the directions at http://help.sap.com/saphelp_nw04/helpdata/en/3a/4a0640d7b28f5ce10000000a155106/content.htm ).
    The you can login using the SAP* account. After which you can go in to the User Administrator and update the j2ee_admin account password. Then logout, disable the Emerengy User (SAP*), and login using the j2ee_admin account.
    hope this would resolve your issue. If still it persists, do revert.
    Regards,
    P. Kumaravel.
    Ps: Award points for heelpful answers.

  • SDM still not working with Java v6u15

    I keep waiting for Java to work some day with their updates on Cisco SDM. Update 14 at least allowed SDM to open. But the new update 15 still hasn't passed the test of clicking on the Configure button and then the Additional Task button. It just doesn't do anything. If it is something that Cisco can fix, please be aware.
    Thanks,
    .. Jim ..

    Hi Jim, you need to downgrade the JAVA version on the computer you want to use SDM.
    SDM does not support java after: 6u3.
    Cisco SDM requires Sun Java Runtime Environment (JRE). The following versions are supported:
    •JRE 1.5_09
    •JRE1.4.2_08
    •JRE 1.5.0_06
    •JRE 1.5.0_07
    •JRE 1.6.0_02
    •JRE 1.6.0_03
    As per the release notes.
    http://www.cisco.com/en/US/docs/routers/access/cisco_router_and_security_device_manager/software/release/notes/SDMr25.html
    This will resolve your issue.
    Cisco does not plan to fix this as SDM is end of life.
    The product that replaces SDM is CCP: Cisco Configuration Professional, that one works with JAva 6 update 14, but it's a different product. It's also a freeware you can download from our website.

  • Mapping editor not working with Java 5 classes

    I have a small protoype web service which I wrote using Tomcat/Axis/Spring/Hibernate and using EJB3 annotations for the mappings. I want to port the persistence layer to Toplink.
    I installed Toplink 9.0.4.1 and added the toplink libraries to my project and implemented the DAO and the spring bean defs.
    I opened the mapping editor and created a project. When I try to add classes to it for mapping I get an error that it can't find the classes (even though I selected them from the chooser). I figured it might be that they were compiled with Java 5, so I switched the JRE_HOME in setenv.cmd to my Java 5 JRE. Now I can import the classes and see the attributes but when I click on any of them in the Navigator panel, the editor panel remains blank. If I now try to save, I get:
    java.lang.NullPointerException
         at oracle.toplink.workbench.ui.tools.CheckListModel.getRowCount(CheckListModel.java:119)
         at javax.swing.JTable.checkLeadAnchor(JTable.java:2949)
         at javax.swing.JTable.tableChanged(JTable.java:2993)
         at javax.swing.JTable.setModel(JTable.java:2827)
         at oracle.toplink.workbench.ui.tools.CheckList.initialize(CheckList.java:47)
         at oracle.toplink.workbench.ui.tools.CheckList.<init>(CheckList.java:26)
    It seems that the mapping workbench doesnt work with Java 5. What should I do?

    Ah, I see. I saw another post here stating that must use 10.1.3.

  • Delete and renameto not working in java

    guys, i have written a java program that reads file1 into temp file and finally writes into another file. program is working fine with no errors, it even reported that the file is deleted. But actually the file was not deleted and renameto was never successful. could you guys see any problem with file definetion so that delete is not successful. please see code from 6th line from bottm.
    public class Mergewrs {public static void main (String[] args) throws IOException {
    /* Creates a new instance of mergewrsFile */
         /* Making sure an argument is specified */
         if(args.length > 0)
              String line           = null;
              String policyflag      = null;
              int addCnt          = 0;
              File mergein = new File("c:\\javat\\mergein.dat");
              /* Specifiying input file to be used */
              BufferedReader  inFile  = new BufferedReader(new FileReader(mergein));
              line = inFile.readLine();
              /* Read all lines in the wrsfile specified */
              while(line != null)
                   System.out.println("Process1: ");
                   policyflag      = line.substring(0,1);
                   // Reads input record from 2 thru 1025
                   String actionIndicator = new String();
                   if(policyflag != null && policyflag.equalsIgnoreCase("A"))
                        { actionIndicator = "A";
                          addCnt = addCnt+1;
                          process(actionIndicator, line);
                   catch(IOException e)
                        {System.err.println("File input error");}
                   line = inFile.readLine();
              } //while ends
         } //if ends
    public static void process(String actionIndicator, String line) throws IOException
         String line1 = null;
         String templine = null;
         String policyId = null;
         File policyOutfile = new File("c:\\javat\\mergeout.dat");
         File policyOutfileold = new File("c:\\javat\\mergeoutold.dat");
         BufferedReader  policyOut  = new BufferedReader(new FileReader(policyOutfile));
         File tempfile = new File("c:\\javat\\tempfile.dat");
         BufferedWriter tempout = new BufferedWriter(new FileWriter(tempfile));
         line1 = policyOut.readLine();
         try{
              policyId =line1.substring(150,165);
              while(line1 != null)
              {     policyId =line1.substring(150,165);
                   try
                        if(policyId.equals(line.substring(151,166)))
                             { templine =line1.substring(0,151);
                        else { templine=line1;}
                        tempout.write(templine);
                        tempout.newLine();
                        line1 = policyOut.readLine();
                   catch (Exception e) {System.err.println("File exception h");}
              } //while ends
              try { tempout.close(); }
              catch (Exception e) { e.printStackTrace();}
              try { policyOut.close(); }
              catch (Exception e) { e.printStackTrace();}
              try
                   if(policyOutfile.exists())
                        policyOutfile.delete();
                        tempfile.renameTo(policyOutfile);
              catch (Exception e) {System.out.println("error"); }
    }

    guys, i have written a java program that reads file1
    into temp file and finally writes into another file.
    program is working fine with no errors, it even
    reported that the file is deleted. But actually the
    file was not deleted and renameto was never
    successful. could you guys see any problem with file
    definetion so that delete is not successful. please
    see code from 6th line from bottm.Since you don't actually do anything with the return value how do you know it was successful?

  • Auto Boxing not working in Java 6?

    Hi All,
    I am studying and practicing to become Java Certified and I am just using an example from the Java Certification Guide Chapter 11 Swing Components from Sybex for Java 5.
    I am using Eclipse and the latest Java 6 SDK in WIndows XP.
    The code below runs fine in Solaris 10 using Java 1.5.0_14-b03:
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class StringLengthTableModel extends AbstractTableModel {
         private String[] strings;
         public StringLengthTableModel(String[] strings) {
              this.strings = strings;
         public int getRowCount() {
              return strings.length;
         public int getColumnCount() {
              return 2;
         public Object getValueAt(int row, int col) {
              if (col == 0) {
                   return strings[row];
              } else {
                   return strings[row].length();
         public String getColumnName(int col) {
              return (col == 0) ? "String" : "Length";
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              String[] strings = { "January", "February", "March", "April", "May",
                        "June", "July", "August", "September", "October", "November",
                        "December" };
              StringLengthTableModel model = new StringLengthTableModel(strings);
              JTable table = new JTable(model);
              frame.getContentPane().add(table);
              frame.setSize(500, 250);
              frame.setVisible(true);
    However in Windows XP and using the latest Eclipse IDE and the Latest Java 6 SDK I get:
    Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
         Type mismatch: cannot convert from int to Object
    The questionable method line is
                   return strings[row].length();
    in the method
         public Object getValueAt(int row, int col) {
              if (col == 0) {
                   return strings[row];
              } else {
                   return strings[row].length();
    Any ideas????
    You would think and hope the latest release of Java like Java 6 would be backward compatible with the auto boxing and auto un boxing features that were introduced in Java 5.
    Any comments, thoughts, ideas would be appreciated.
    Thanks,
    Carlos A. Morillo
    [email protected]

    CarlosMorillo wrote:
    Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
         Type mismatch: cannot convert from int to ObjectGo to that line in Eclipse and look for the red squiggly line. Click on the I symbol next to it. At a guess the project is set up to work in 1.4 mode.
    Also learn to love the "Problems" panel. This should not have been a runtime error.
    Any ideas????Your project is in 1.4 mode. Right click on the project in the "Project Explore" window. Select properties, select "Java Compiler", check the "Enable project specific settings" and make sure the little drop downs all say "6.0".

  • URL class is not working in Java 1.4. However works in Java 1.3

    I have a Java program which uses URL classes through FTP connection to open any files. It works fine in Java 1.3 version. However the same program fails with
    java.io.FileNotFoundException: at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream
    when using Java 1.4 version.
    Here is the part of source code.
    try
    URL url ;
    url = new URL("ftp://"); // I have not given the full connect string here.
    URLConnection connection = url.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine) ;
    in.close();
    catch(Exception e)
    System.out.println("Error occured " + e.getMessage());
    Anyone has ideas about what is going wrong and how to correct that. I appreciate your reply.
    Thanks

    Here is the original code. I have not given the password and using as "anonymous". Again this code works fine in Java1.3. But not in Java1.4 . I appreciate your help .Is it something I have to set up in UNIX side. The exact error is
    <p>
    "Exception in thread "main" java.io.FileNotFoundException: oraom/temp.log
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnec
    tion.java:333)
    at java.net.URL.openStream(URL.java:913)
    at temp.main(temp.java:17) "
    <P>
    import java.net.*;
    <P>
    import java.io.*;
    <P>
    import java.util.*;
    <P>
    public class temp
    <P>
    <P>
    public static void main(String args[]) throws Exception
    <P>
    <P>
    URL url = new URL("ftp://oraom:anonymous@oradev:/oraom/temp.log");
    <P>
    try
    <P>
    <P>               
    URLConnection connection = url.openConnection();
    <P>
    connection.setDoInput(true);
    <P>
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    <P>
         String inputLine;
    <P>
         while ((inputLine = in.readLine()) != null)
    <P>
         System.out.println(inputLine) ;
    <P>
         in.close();
    <P>
    <P>
    catch(Exception e)
    <P>
    <P>
    throw e;
    <P>
    <P>                                                  
    <P>
    <P>
    </P>

Maybe you are looking for

  • Oracle trace on events

    hi gurus.. please anybody explain me what is the difference between event based trace (eg 10046,10053) and a normal trace using alter session ? At what condition it is recommended to use? is it still using as latest dbms_monitor package is available

  • "1F" will not disappear.....

    I have what appears to be a "notification" from the facebook app that will not disappear....I constantly have the "1F" symbol on my screen....I have accessed my facebook account both via the facebook BB application and the browser to insure that noth

  • How I know if my computer have a virus?

    My computer is slow and the itunes show up by his self? is a virus?

  • HDMI Adapter no longer charges new iPad ?

    I bought a shiny new iPad 3rd Gen, and am having difficulties with my existing Apple HDMI Adapter, which, apart from the "This accessory is not supported" popup, will not charge the device even when being plugged to an iPad Power Adapter. Have any of

  • How to create a Database programatically?

    Hi, I couldnt not find the words to describe the below question in short for the title: I am working on a Java application that runs of a JDBC database. I need to be able to create a new database if the application is run on the system for the first