File open in java

I have created a small application to upload any file and save it in a temporary directory.
Then display all the file names which are in that directory.here's my code ....
MultipartRequest mr = null;
               try {
                    mr = new MultipartRequest(req, ".");                              
                    BufferedReader br = new BufferedReader(new FileReader(fileName = (String)mr.getFilesystemName("importFile")));
               } catch(Exception e) { System.out.println("Error uploading from file '"+fileName+"': "+e); e.printStackTrace();
               } finally { new File(fileName).delete(); }
               String dir = "C:\\asta-timesheet\\temp\\";
               Vector fileVector = new Vector();
               boolean result = false;
               DataInputStream dis;
               FileInputStream fin;
               try {               
                    String fileContent = "";
                    Enumeration files = mr.getFileNames();
                    String name = (String)files.nextElement();
                    String filename = mr.getFilesystemName(name);
                    String type = mr.getContentType(name);
                    File f = mr.getFile(name);
                    FileReader fs = new FileReader(f);
                    BufferedReader in = new BufferedReader(fs);
                    String s, s2 = new String();
                    while((s = in.readLine())!= null) {
                    s2 += s + "\n";
                    fileContent = s2;     
                    in.close();                                                                 
               File file = new File(dir, fileName);           
     // Create file if it does not exist
     boolean success = file.createNewFile();
     if (success) {              
                         InputStream inn = new FileInputStream(f);
               OutputStream out = new FileOutputStream(file);
               // Transfer bytes from in to out
                    byte[] buf = new byte[1024];
                    int len;
               while ((len = inn.read(buf)) > 0) {
               out.write(buf, 0, len);
               inn.close();
               out.close();
     } else {
     // File already exists     
     req.setAttribute("fileStatus", "exists");
          } catch(Exception e) { System.out.println("Error uploading from file '"+fileName+"': "+e); e.printStackTrace();}
               File dirr = new File(dir);
          String[] children = dirr.list();
          if (children == null) {
          } else {
          for (int i=0; i<children.length; i++) {                    
          String filename = children;
          // The list of files can also be retrieved as File objects
          File[] files = dirr.listFiles();
          for (int i = 0; i < files.length; i++) {
                    File f = files[i];                                                                           
               req.setAttribute("fileVector", files);                    
          return returnPage;
I need help with opening up the listed files.i.e if its a word doc.i need it to be open on ms word.I have file types like excel,jpg,txt....Can someone pls explain or provide code for this.
thx in advance.

All you could use to detect the correct type would be the extension which might or might not be accurate. We'll assume for a moment that the extensions will be accurate. What you need to look into running native code. Follow the bouncing link.
http://www.google.com/search?hl=en&q=Java+%2B+native+code&btnG=Google+Search
Hope this helps,
PS.
One more thing, please use code tags when you're posting code, it makes it much easier to read.
Message was edited by:
puckstopper31

Similar Messages

  • How to close external files opened via java via java itself?

    hi,
    I am using jdk1.6 so I've used the Desktop Class to run the .bat file for some purposes via java with the open(File f) method. Now, what I want is to close those opened .bat files but had no idea so I would appriciate any help.
    thank you,
    Jay

    Okay, now I've used the ProcessBuilder class for that
    approach. Now I can find the destroy() method in the
    Process class but it didn't help me. Here's how I
    tried:
    public class Main extends JFrame implements
    ActionListener
    Command com;
    public Main()
    super();
    com=new Command(1,this); // this class
    class implements ActionListener and handles the
    actions happening in the Main class.
    a_button.addActionListener(com);
    /* from the Command class the ProcessBuilder is
    der is started returning the instance proc of the
    class Process.*/
    public void windowClosing(WindowEvent evt)
    com.proc.destryo(); //<------ does the API really have a typo in it?
    System.exit(0);
    public void window.....(WindowEvent evt){}....
    }regards,
    Jay

  • How can I open in java file a text file?

    Hi !
    For example I have a java file name Pencil.java and I have a text fie name Box.txt
    I want like that if ( a == b ) {open Box.txt}
    How can I do that ?
    Thanks.

    Yes I want to see what this text file contains. Like clicking to a text file with mouse and opens. Then I can see what it contains.
    I have a Java document Pencil.java and I have a text file Box.txt
    I will write a java code in pencil.java ( that I dont know ). Then when I enter a number from keyboard with
    Scanner write = new Scanner(System.in);
    int a = write.nextInt()
    if (a == b) {                } opens Box.txt
    For example
    I write to command prompt
    java pencil
    It wants from me a number : I will enter 3.
    It is same as b .
    Then Box.txt file opens.
    Edited by: zue on Jun 3, 2008 11:04 AM

  • How to open external files in a Java stored procedure?

    Hi y'all,
    I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
    BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
    I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
    Your help is greatly appreciated,
    Gary

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Gary Nool ([email protected]):
    Hi y'all,
    I'm trying to open an external text file from a Java stored procedure. The java sp has been successfully loaded, resolved, published, etc. in Oracle. I'm using the following statement to try to open the file (enclosed in a try/catch block):
    BufferedReader fileObj = new BufferedReader(new FileReader("fileName.txt"));
    I'm getting a file not found error. Where is Oracle looking (i.e., what directory)?
    Your help is greatly appreciated,
    Gary<HR></BLOCKQUOTE>
    Hi Gary,
    you must use a "database directory", e.g:
    SQL>create directory WORKING_DIR as '/home2/common/';
    SQL> select * from all_directories;
    OWNER DIRECTORY_NAME
    DIRECTORY_PATH
    SYS WORKING_DIR
    /home2/common/
    Gert

  • Open a file into a java app - HOW DO YOU DO IT!!

    I have written an html/php editor - I want to set it up so that when you double click on a php file in windows it will open the file into my java ide.
    I know this can be done - but how!!! There does not seem to be any info on the web about it - can anyone give me some pointers.
    Thanks

    Yeah - but the problem is: You can only set files to
    open with a .exe file - if you go to the settings and
    set the .php file to "open with" you have to select a
    .exe file e.g. notepad.exe
    However you can't create .exe files in java!!!! So how
    do you do it?You have to spend $$$'s
    However many /most converters don't work without the relevant updated JVM (but they are *.exe, kind of)

  • BUG : JDev 10.1.3 SR2 hangs when opening a java files

    Hi,
    think I've found a bug. I'm using JDev 10.1.3, patched with SR1 & 2, my machine is a Windows XP SP2 box with 1GB mem and Intel Pentium 4 2.60 Ghz with HT.
    When I try to open a file in the Java editor the IDE hangs. Launching jdev.exe I can see that the following output is continuously printed:
    Exception occurred updating RowMap: 16
    startRow: 0
    numRows: 1
    startLine: 0
    numLines: 15
    _rowCount: 15
    lineCount: 15
    Stack trace follows
    java.lang.ArrayIndexOutOfBoundsException: 16
         at oracle.javatools.buffer.ArrayLineMap.getLineEndOffset(ArrayLineMap.java:326)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateLineWidths(BasicView.java:3576)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateRows(BasicView.java:3487)
         at oracle.javatools.editor.BasicView$LineRowMap.handleInsert(BasicView.java:3315)
         at oracle.javatools.editor.BasicView$LineRowMap.rebuildRowMap(BasicView.java:3286)
         at oracle.javatools.editor.BasicView$LineRowMap.<init>(BasicView.java:3259)
         at oracle.javatools.editor.BasicView$FoldedRowMap.<init>(BasicView.java:3966)
         at oracle.javatools.editor.BasicView.updateMetrics(BasicView.java:1128)
         at oracle.javatools.editor.BasicView.getPreferredSpan(BasicView.java:1730)
         at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1257)
         at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:819)
         at oracle.javatools.editor.BasicEditorUI.getPreferredSize(BasicEditorUI.java:158)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
         at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1227)
         at javax.swing.JViewport.getViewSize(JViewport.java:1003)
         at javax.swing.plaf.basic.BasicScrollPaneUI.syncScrollPaneWithViewport(BasicScrollPaneUI.java:264)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.viewportStateChanged(BasicScrollPaneUI.java:855)
         at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:797)
         at javax.swing.JViewport.fireStateChanged(JViewport.java:1357)
         at javax.swing.JViewport.setView(JViewport.java:975)
         at oracle.ideimpl.editor.SplitPane.setEditorComponent(SplitPane.java:343)
         at oracle.ideimpl.editor.SplitPane.attachEditor(SplitPane.java:949)
         at oracle.ideimpl.editor.SplitPane.attachCurrentEditor(SplitPane.java:919)
         at oracle.ideimpl.editor.SplitPane.setCurrentEditorStatePos(SplitPane.java:1138)
         at oracle.ideimpl.editor.SplitPane.setSplitPaneState(SplitPane.java:207)
         at oracle.ideimpl.editor.TabGroup.attachCurrentNode(TabGroup.java:517)
         at oracle.ideimpl.editor.TabGroup.setCurrentTabGroupState(TabGroup.java:1294)
         at oracle.ideimpl.editor.TabGroup.activateEditor(TabGroup.java:639)
         at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1273)
         at oracle.ideimpl.editor.EditorManagerImpl.createEditor(EditorManagerImpl.java:1196)
         at oracle.ideimpl.editor.EditorManagerImpl.openEditor(EditorManagerImpl.java:1131)
         at oracle.ideimpl.editor.EditorManagerImpl.whenOpenEditor(EditorManagerImpl.java:2332)
         at oracle.ideimpl.editor.EditorManagerImpl.handleDefaultAction(EditorManagerImpl.java:1893)
         at oracle.ide.controller.ContextMenu.fireDefaultAction(ContextMenu.java:343)
         at oracle.ideimpl.explorer.BaseTreeExplorer.fireDefaultAction(BaseTreeExplorer.java:1504)
         at oracle.ideimpl.explorer.BaseTreeExplorer.dblClicked(BaseTreeExplorer.java:1841)
         at oracle.ideimpl.explorer.BaseTreeExplorer.mouseReleased(BaseTreeExplorer.java:1862)
         at oracle.ideimpl.explorer.CustomTree.processMouseEvent(CustomTree.java:176)
         at java.awt.Component.processEvent(Component.java:5253)
         at java.awt.Container.processEvent(Container.java:1966)
         at java.awt.Component.dispatchEventImpl(Component.java:3955)
         at java.awt.Container.dispatchEventImpl(Container.java:2024)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
         at java.awt.Container.dispatchEventImpl(Container.java:2010)
         at java.awt.Window.dispatchEventImpl(Window.java:1774)
         at java.awt.Component.dispatchEvent(Component.java:3803)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Forcing RowMap rebuild
    I also disabled ALL extension and removed the jar files in jdev/extension, except the one that was originally included in the 10.1.3 and those that seems related to the service releases.
    The file I'm trying to open is done like this:
    --- start after this line ---
    package com.websiteitalia.jsftest.view.controllers.people.list;
    import com.websiteitalia.jsftest.model.list.people.PeopleListUtil;
    import com.websiteitalia.jsftest.view.controllers.BaseListBacker;
    import com.websiteitalia.weblib.ejb.list.IWSList;
    public class PeopleListBacker extends BaseListBacker {
    public IWSList getListRemote() throws Exception {
    return PeopleListUtil.getList();
    --- end before this line ---
    I include also an HEX encoding of the file:
    00000000h: 70 61 63 6B 61 67 65 20 63 6F 6D 2E 77 65 62 73 ; package com.webs
    00000010h: 69 74 65 69 74 61 6C 69 61 2E 6A 73 66 74 65 73 ; iteitalia.jsftes
    00000020h: 74 2E 76 69 65 77 2E 63 6F 6E 74 72 6F 6C 6C 65 ; t.view.controlle
    00000030h: 72 73 2E 70 65 6F 70 6C 65 2E 6C 69 73 74 3B 0D ; rs.people.list;.
    00000040h: 0A 0D 0A 69 6D 70 6F 72 74 20 63 6F 6D 2E 77 65 ; ...import com.we
    00000050h: 62 73 69 74 65 69 74 61 6C 69 61 2E 6A 73 66 74 ; bsiteitalia.jsft
    00000060h: 65 73 74 2E 6D 6F 64 65 6C 2E 6C 69 73 74 2E 70 ; est.model.list.p
    00000070h: 65 6F 70 6C 65 2E 50 65 6F 70 6C 65 4C 69 73 74 ; eople.PeopleList
    00000080h: 55 74 69 6C 3B 0D 0A 69 6D 70 6F 72 74 20 63 6F ; Util;..import co
    00000090h: 6D 2E 77 65 62 73 69 74 65 69 74 61 6C 69 61 2E ; m.websiteitalia.
    000000a0h: 6A 73 66 74 65 73 74 2E 76 69 65 77 2E 63 6F 6E ; jsftest.view.con
    000000b0h: 74 72 6F 6C 6C 65 72 73 2E 42 61 73 65 4C 69 73 ; trollers.BaseLis
    000000c0h: 74 42 61 63 6B 65 72 3B 0D 0A 69 6D 70 6F 72 74 ; tBacker;..import
    000000d0h: 20 63 6F 6D 2E 77 65 62 73 69 74 65 69 74 61 6C ; com.websiteital
    000000e0h: 69 61 2E 77 65 62 6C 69 62 2E 65 6A 62 2E 6C 69 ; ia.weblib.ejb.li
    000000f0h: 73 74 2E 49 57 53 4C 69 73 74 3B 0D 0A 0D 0A 0D ; st.IWSList;.....
    00000100h: 0A 70 75 62 6C 69 63 20 63 6C 61 73 73 20 50 65 ; .public class Pe
    00000110h: 6F 70 6C 65 4C 69 73 74 42 61 63 6B 65 72 20 65 ; opleListBacker e
    00000120h: 78 74 65 6E 64 73 20 42 61 73 65 4C 69 73 74 42 ; xtends BaseListB
    00000130h: 61 63 6B 65 72 20 7B 0D 0A 20 20 20 20 0D 0A 20 ; acker {..    ..
    00000140h: 20 20 20 70 75 62 6C 69 63 20 49 57 53 4C 69 73 ; public IWSLis
    00000150h: 74 20 67 65 74 4C 69 73 74 52 65 6D 6F 74 65 28 ; t getListRemote(
    00000160h: 29 20 74 68 72 6F 77 73 20 45 78 63 65 70 74 69 ; ) throws Excepti
    00000170h: 6F 6E 20 7B 0D 0A 20 20 20 20 20 20 20 20 72 65 ; on {..        re
    00000180h: 74 75 72 6E 20 50 65 6F 70 6C 65 4C 69 73 74 55 ; turn PeopleListU
    00000190h: 74 69 6C 2E 67 65 74 4C 69 73 74 28 29 3B 0D 0A ; til.getList();..
    000001a0h: 20 20 20 20 7D 0D 0A 20 20 20 20 0D 0A 7D 0D 0A ; }.. ..}..
    Note the last empty line before the end-of-file. If I try to past this code into a Java file and open it in JDev, it hangs as described.
    Moreover, if I remove the last empty line, JDev will open the file in the editor but, as soon as I enter it again (placing the cursor at the end of the file a hitting enter) JDev hangs again.
    A final note: I experienced many hangs also in JSP editor, especially selecting a block of text and pasting something in its place, but don't know if the two behaviours are related.

    Ok, maybe I've tracked down at least one factor that makes JDev hang. I changed my font back to the default "DialogInput" instead of "Lucida Console" and now it opens my file.
    This is the settings that works in system/oracle.jdeveloper.10.1.3.36.73/preferences.xml
    <Item>
    <Key>FontSizeOptions</Key>
    <Value class="oracle.ide.ceditor.options.FontSizeOptions">
    <fontFamily>DialogInput</fontFamily>
    <fontSize>12</fontSize>
    <showOnlyFixedWidth>false</showOnlyFixedWidth>
    </Value>
    </Item>
    With this one it hangs:
    <Item>
    <Key>FontSizeOptions</Key>
    <Value class="oracle.ide.ceditor.options.FontSizeOptions">
    <fontFamily>Lucida Console</fontFamily>
    <fontSize>12</fontSize>
    <showOnlyFixedWidth>false</showOnlyFixedWidth>
    </Value>
    </Item>
    Logging the exception
    Exception occurred updating RowMap: 16
    startRow: 0
    numRows: 1
    startLine: 0
    numLines: 15
    _rowCount: 15
    lineCount: 15
    Stack trace follows
    java.lang.ArrayIndexOutOfBoundsException: 16
         at oracle.javatools.buffer.ArrayLineMap.getLineEndOffset(ArrayLineMap.java:326)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateLineWidths(BasicView.java:3576)
         at oracle.javatools.editor.BasicView$LineRowMap.recalculateRows(BasicView.java:3487)
         at oracle.javatools.editor.BasicView$LineRowMap.handleInsert(BasicView.java:3315)
         at oracle.javatools.editor.BasicView$LineRowMap.rebuildRowMap(BasicView.java:3286)
         at oracle.javatools.editor.BasicView$LineRowMap.<init>(BasicView.java:3259)
         at oracle.javatools.editor.BasicView$FoldedRowMap.<init>(BasicView.java:3966)
         at oracle.javatools.editor.BasicView.updateMetrics(BasicView.java:1128)
         at oracle.javatools.editor.BasicView.getPreferredSpan(BasicView.java:1730)
         at javax.swing.plaf.basic.BasicTextUI$RootView.getPreferredSpan(BasicTextUI.java:1257)
         at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:819)
         at oracle.javatools.editor.BasicEditorUI.getPreferredSize(BasicEditorUI.java:158)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1615)
         at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1227)
         at oracle.javatools.editor.gutter.LineGutterPlugin.getRowCount(LineGutterPlugin.java:1485)
         at oracle.javatools.editor.gutter.LineGutterPlugin.getPreferredSize(LineGutterPlugin.java:890)
         at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:690)
         at java.awt.Container.preferredSize(Container.java:1558)
         at java.awt.Container.getPreferredSize(Container.java:1543)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
         at javax.swing.ViewportLayout.preferredLayoutSize(ViewportLayout.java:78)
         at java.awt.Container.preferredSize(Container.java:1558)
         at java.awt.Container.getPreferredSize(Container.java:1543)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1617)
         at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:717)
         at java.awt.Container.layout(Container.java:1401)
         at java.awt.Container.doLayout(Container.java:1390)
         at java.awt.Container.validateTree(Container.java:1473)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validateTree(Container.java:1480)
         at java.awt.Container.validate(Container.java:1448)
         at java.awt.Window.show(Window.java:515)
         at oracle.ideimpl.MainWindowImpl.show(MainWindowImpl.java:572)
         at java.awt.Component.show(Component.java:1300)
         at java.awt.Component.setVisible(Component.java:1253)
         at oracle.ideimpl.MainWindowImpl$2.runImpl(MainWindowImpl.java:773)
         at oracle.javatools.util.SwingClosure$1Closure.run(SwingClosure.java:50)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    Forcing RowMap rebuild

  • I can`t open jar files though my java version is updated

    Hello everybody, I`m using Macbook Pro 13` with Lion on it.
    As it says in the title, I can`t open jar files though, my java version is updated.
    It says, I shuld check the console.
    Right now, my java version is, "1.7.0_15", and i`m trying to open a jar file created 3 days ago, by some developer.
    Although, if im trying to open jar file created 1 year ago, it doe`s open.
    Why is that? and, How can i fix it?
    Thanks.

    Franeo wrote:
    Hello everybody, I`m using Macbook Pro 13` with Lion on it.
    As it says in the title, I can`t open jar files though, my java version is updated.
    It says, I shuld check the console.
    With Java 6 and prior, you had to enable logging first before you could view error messages in Console.  I am guessing that you need to check the Java Control Panel to see if logging is turned on.

  • Opening a java jar file through a labview program

    Hello,
    I need to open a java jar file in labview........this jar file is a GUI with multiple frames and has buttons on each frame help navigate through between frames....i just require the program to open it and close it based on some signals so then i won't have to do it manually

    LabVIEW doesn't have any control over what happens in a system exec, as you give the control to the system. You can, however, check the process list through .NET commands and kill the process (You should be able to stop it through "taskkill /F /im java.exe"). Not the prettiest solution, but should work.
    /Y
    LabVIEW 8.2 - 2014
    "Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
    G# - Free award winning reference based OOP for LV

  • Opening a .java file in xp

    New to java and have written a small program in notepad, compiled and i ran the program. everything is fine via the dos prompt. i wanted to go and edit the file Sample.java. When i double click i get a message program not found "program.exe" is there a special way that i need to open the .java file in order to edit the contents. is there a free telnet application i can download in order to make this easier instead of going throught the command prompt

    Hi ,
    ok ..
    I will provide the best and permanent solution for you problem.
    Open window explore and clik on Tools and window options.
    New window will open click on file type and enter the extension .java
    and click on the advance option select the program you want open such as notepate/textpate/editplus...etc.then after when you click on the java program it will automatically open on the notepad only.
    just try it out..
    With Regards
    Elan

  • Loadjava Error while opening file: –resolve  Exception java.io.FileNotFound

    Dears,
    I'm having Oracle 11gr2 on Windows 2008r2. I have very strange issue while trying to load ordinary Java source. I get error that loadjava can't open file. I'm using the following command in loading:
    %ORACLE_HOME%\dbhome_1\BIN\loadjava -thin -user ORAMQ/***@localhost:1521:DEVAR -verbose -fileout %C:\temp\loadjava-9-MQReasonCodeResolver.java.log C:\src\MQReasonCodeResolver.java –resolve-----
    I got the following error in the verbose file out:
    arguments: '-user' 'ORAMQ/***@localhost:1521:DEVAR' '-thin' '-verbose' '-fileout' 'C:\temp\loadjava-9-MQReasonCodeResolver.java.log' 'C:\src\MQReasonCodeResolver.java' '–resolve'
    creating : source MQReasonCodeResolver
    loading  : source MQReasonCodeResolver
    Error while opening file: –resolve
        Exception java.io.FileNotFoundException: –resolve (The system cannot find the file specified)
    creating :  –resolve
    The following operations failed
         –resolve: opening file-----
    The code is very simple and doesn't have any issue:
    import java.lang.reflect.Field;
    public class MQReasonCodeResolver
        public MQReasonCodeResolver()
        public static final String MQ_EXCEPTION_CLASS = "com.ibm.mq.MQException";
        public static final String RC_FIELD_PREFIX = "MQRC_";
        public static final String RC_VALUE_FIELD = "reasonCode";
        public static String resolve( Exception mqex )
            if ( !canResolve( mqex ) )
                return mqex.getClass().toString() + mqex.getMessage();
            Class class1 = mqex.getClass();
            try
                Field field = class1.getField( RC_VALUE_FIELD );
                Object key = field.get( mqex );
                Field[] fields = class1.getFields();
                for ( int i = 0; i < fields.length; i++ )
                    Field ff = fields;
    String name = ff.getName();
    if ( name.startsWith( RC_FIELD_PREFIX ) && ff.get( null ).equals( key ) )
    return mqex.getMessage() + " " + name;
    catch ( Exception ex )
    return "unknown";
    public static boolean canResolve( Exception exx )
    Class class1 = exx.getClass();
    while ( Exception.class.isAssignableFrom( class1 ) )
    if ( MQ_EXCEPTION_CLASS.equals( class1.getName() ) )
    return true;
    class1 = class1.getSuperclass();
    return false;
    I load other classes and no issue, even jar files, I don't know what is the problem with this file? Also, it is strange is creating class and loading it has no issue, but the issue comes when resolve.
    Can anyone help?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi:
    Put your -resolve flag at the beginning of the list of arguments.
    Latest arguments should be files to be uploaded by loadjava.
    Best regards, Marcelo.

  • Opening a java script file

    How do I use notepad to open a java script file.

    Encephalopathic wrote:
    This reminds me of one of my favorite urban legends, the "too stupid to own a computer" legend:
    http://www.snopes.com/humor/business/wordperfect.asp
    it's a classic!That made me remember back in the day when I was convinced you had to power cycle your monitor when you rebooted your computer. :( Ah, to be young and ignorant again.

  • How to open an MS-Word-File from a Java-Applikation ?

    Hi,
    i want to open an MS-Word-File from a Java-Applikation.
    Something like this:
    File myFile = new File("myFile.doc");
    myFile.open(); //unfortunately this methode doesn't exist
    Thanks for response

    In my opinion you have to use the Runtime.exec(String) method. I do not know the program name for msword.
    You can open a file in notepad by invoking the method Runtime.getRuntime().exec("notepad c:/xyz/abc.txt");
    Runtime runTime = Runtime.getRuntime();
    runTime.exec("programName" + " " + file);
    Of course the computer on which the program runs must have the application!
    Hope this helps!

  • Open a java file from c#

    Does anyone know if it's possible to open a java file from a c# web form?
    Any links would also be appreciated,
    Thanks,
    Clivert

    I don't know anything about C# web forms (that's pretty far away from the topic of this forum) but I expect anybody answering the question would need to know what you mean by "open" and "a java file" in that context.
    For example it might mean to cause a text editor to run and display the source code for a Java class. Or it might mean for a Java JVM to start running and execute the main method of a Java class.

  • Maximum simultaneous opened files in a java thread on linux 1.4.20

    Hello,
    It seems like a maximum of 1024 files can be opened by a processus on linux (in java, a thread is a linux processus).
    Is it possible to change this value, or has it been set at the JVM compilation?
    I created a nio server, and one thread is to manage thousands of connections. For the moment I can't pass 1010 connections.
    As a fast test, I created the following source :
    public class MaxOpenedFilesTest {
    /** Creates a new instance of MaxOpenedFilesTest */
    public MaxOpenedFilesTest() {
    * @param args the command line arguments
    public static void main(String[] args) {
    File f = new File("/home/greg/a.out");
    FileInputStream[] stream = new FileInputStream[2000];
    try {
    for (int i=0; i<stream.length; i++) {
    stream[i] = new FileInputStream(f);
    System.out.println(i+" files opened");
    catch (Exception e) {
    System.out.println("ERROR : "+e);
    e.printStackTrace();
    This test throws an IOException at 1019 files opened : Too many opened files...
    I have tested a lot of things. I even recompiled the linux kernel. Changed the NR_OPEN, OPEN_MAX, __FD_SETSIZE, etc... Still don't work.
    I havve set the global maximum file descriptor to 65536. It works. But for one thread, I can't have more than 1019 file descriptors (must be the 1024 initial limit defined by the kernel)...
    Could somebody help.
    It would be great.
    Thank you.
    Gr�goire.

    Thank you for your answer.
    I have already done all the described procedures in the link you provided.
    In fact, I used this link :
    file:///home/greg/1_NetNoLedge/LinuxTuning/linux.html
    and this other one :
    file:///home/greg/1_NetNoLedge/LinuxTuning/s1-custom-kernel-modularized.html
    Still only 1024 files allowed to be opened for one process...
    In your link, it is said :
    You need to give processes the option of increasing their file descriptor limits:
    In /etc/security/limits.conf add two lines:
    * soft nofile 1024
    * hard nofile 4096
    Suggesting that it wouldn't even be necessary recompile the kernel to allow more opened file descriptors in a process... This really isn't clear for me.
    Thank you.

  • How to open java files in a java project

    hi ,
    i have to implement a java program analyzer and now i have implement a java parser using javaCC. My parser parse a java file at a time and i have to read and parse all java files in a java project. my idea is to enter
    java project name *.jpx as an input and search java files in project and parse them one by one, or , to enter the folder path of java source files of project and parse them.
    i am a beginer of java language and i don't know where to start to do it.
    is there someone tell me which way is easier and better for my case and some ways to implement it. i search sample files that is similar to my case but i cannot find any.
    thanks in advance.
    ami

    if u don't mind , can u tell me which tutorial i
    should read for that? http://java.sun.com/docs/books/tutorial/essential/io/
    This... for example.
    xH4x0r

Maybe you are looking for