Openning cd rom in java

I hava a question for everyone in this forum.
Anyone can tell me that may write a code in java that can open the cd rom of my system??????
Is there any class in java that contains method to perform the actions that i have just mentioned ?????
Waiting for your reply...
Thanks

I hava a question for everyone in this forum.
Anyone can tell me that may write a code in java that
can open the cd rom of my system??????
Is there any class in java that contains method to
perform the actions that i have just mentioned ?????
Waiting for your reply...
ThanksNo, there is no "normal" way to do this. If you're on Windows, you could try this hack:
/** @author Michael_Dunn */
class OpenCD
  public OpenCD()
    try
      String driveLetter = javax.swing.JOptionPane.showInputDialog("Enter CD drive letter");
      if(driveLetter != null)
        java.io.File file = new java.io.File("OpenCD.vbs");
        java.io.FileWriter fw = new java.io.FileWriter(file);
        fw.write("CreateObject(\"Shell.Application\").NameSpace(17).ParseName(\""+driveLetter+"\" & \":\\\").InvokeVerb(\"e&ject\")");
        fw.close();
        Runtime.getRuntime().exec("WScript.exe openCD.vbs");
        Thread.sleep(2000);
        file.deleteOnExit();
    catch(Exception e){e.printStackTrace();}
    System.exit(0);
  public static void main(String[] args){new OpenCD();}
}

Similar Messages

  • Error: could not open `C:\Program Files\Java\j2re1.4.0_01\lib\i386\jvm.cfg'

    I am geting this error when I enter the "java" command:
    "Error: could not open `C:\Program Files\Java\j2re1.4.0_01\lib\i386\jvm.cfg'"
    I have configured the PATH variable (Windows 2000) and "javac" works. I cannot, however, get my programs to run because of the error every time I type "java". Also, I did not install my JDK / SDK to the directory in which the computer is looking for the "java" cammand (ie. it is not in 'Program Files'...). If anyone can help, it would be greatly appreciated. Thank you.

    Try using the -cp switch on the command line. For example:java -cp . MyProgramIf this corrects the problem, you need to set the classpath variable
    as well as the path.
    Mark

  • How to open forms in separate Java Applet rather then Internet explorer

    Aslam o Alikum (Hi)
    I want to open my form in separate Java Applet rather then in Internet Explorer.
    Please help
    Best Regards,
    Nasir Zeeshan.

    Aslam o Alikum (Hi)
    Let me explain my question
    when i run my form from application server. it opens a web browser and display my form into it (form display in java applet embbeded in internet explorer). But what i want is that the web browser open the form in java applet as a separate window.
    Is it clear now ?
    Best Regards,
    Nasir Zeeshan.

  • Some web pages need Java Platform to open-Can I download Java for I Phone?

    Cant opend some pages that needs Java to start.
    Where can I download Java Platform for I Phone 3D ?
    Thanks
    J.B

    Ok, It is my first time here on forum, so I posted by mistake the question
    several times SORRY !!!!!!! I tried to take it away but no.
    I have no intentions to "get extra responses".
    Banned ???? You must be joking !!!!
    I have bought a new Iphone 3D and cant open several pages with Java
    and I bring it up on ths forum, What is your problem ??

  • Open Internet explorer from Java

    Hi everyone!
    Doew anybody know how to open IOnternet Explorer from Java.I have tried
    String browserCommand = ("\"C:\Program Files\InternetExplorer\iexplore.exe\"");
         URL theUrl=new URL("http://www.yahoo.com/"); // or whatever
         Runtime.getRuntime().exec(browserCommand+ " "+theURL);
    but something goes wrong with the escape characters I use.
    I would be greatful to receive any advice.
    Thanks in advance!

    or...
        private static boolean showInBrowser(String url){
             String os = System.getProperty("os.name").toLowerCase();
            Runtime rt = Runtime.getRuntime();
            try{
                 if (os.indexOf( "win" ) >= 0) {
                      // this doesn't support showing urls in the form of "page.html#nameLink"
                     rt.exec( "rundll32 url.dll,FileProtocolHandler " + url);
                 } else if (os.indexOf( "mac" ) >= 0) {
                     rt.exec( "open " + url);
                 } else if (os.indexOf( "nix") >=0 || os.indexOf( "nux") >=0) {
                      // Do a best guess on unix until we get a platform independent way
                      // Build a list of browsers to try, in this order.
                      String[] browsers = {"epiphany", "firefox", "mozilla", "konqueror",
                                "netscape","opera","links","lynx"};
                      // Build a command string which looks like "browser1 "url" || browser2 "url" ||..."
                      StringBuffer cmd = new StringBuffer();
                      for (int i=0; i<browsers.length; i++)
                           cmd.append( (i==0  ? "" : " || " ) + browsers[i] +" \"" + url + "\" ");
                      rt.exec(new String[] { "sh", "-c", cmd.toString() });
                 } else {
                      return false;
            }catch (IOException e){
                 return false;
            return true;
        }

  • How can I open a program using Java and then perform certain tasks with it?

    For example, and this is just an example, I want to write a Java program that opens MS Paint and then manipulates that program. This can be useful to automate certain tasks.
    My question is whether this can be done writing Java code and if so how? If not possible, would I need to use a scripting language instead?

    write a Java program that opens MS Paint and then
    manipulates that program. This can be useful to
    automate certain tasks."manipulates" is a too wide term. Let me narrow down:
    1. If you want to open (run) the program and then shut (kill) it down it is possible and fairly trivial to do in java. Look up Runtime and Process classes in java.lang package
    2. If you want to open the program and edit some image/document in the opened program. It is very difficult in java. May be possible... using some Java/COM bridge, assuming your native program is COM/Active-x compliant. Note: these things go beyond the boundary of JVM and needs to interact with host OS and involves shared memory, ipc and all "low level" stuffs.
    If you want to be able to play around with these COM/Activex apps- choose .NET instead :-)
    3) You can open the program from java and pass it some command line arg as in (1) above and then the program will load that document/image at startup automatically. You may then edit the doc/image thru that program itself. However, Java is not doing anything for you here, other than just starting off your native mspaint.exe ot notepad.exe.
    -BJ
    Message was edited by:
    Bimalesh

  • How to open/read file using Java in Unix?

    Hi Friends,
    Can you please help me out how to open/read file using java in unix os? I have create one text file in "/home/test.txt" in unix environment. How to open the same file & read using java code?
    - Hiren Modi

    http://java.sun.com/docs/books/tutorial/essential/io/index.html

  • Opening a  File in Java

    The name of Ms-Exel file is stored in Ms-Access Database.
    Ms-Access Database . Report.dat
    There two Columns
    Rep_Name = which will have the Report Name
    Rep_Excel = Which will have Excel File name
    i will be creating a GUI whereby I will access the database and display the report names.
    Depending on what the user selects I woukd l like to make a call to Excel and Open that respected file for that Rep_Name.
    The File I am opening in Excel will be taken from the MS-ACCESS DATABASE.
    After the report is displayed , on clicking the close button there should be option to come back to the java program

    1. retieve th efilename from th edatabase.
    2. open the excel file
    for #2, if you want tyo open it within your Java application (so your Java application have access to the file..like to modify and update the Excel file)..then you will ned some sort of Excel API, like Jakarta POI as suggested. If you just want to open the excel file using MS Excel application (your Java application will not be able to do anything - like modify the Open Excel file) , then you can use Runtime class and its exec() method to launch the Excel application.

  • 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.

  • How can i open the popup from java class

    Hi,
    Please tell me how can i open the popup from java class.
    I am using jdev 11.1.1.7.0
    I have used the below code which works fine in jdev 2.1 but it will have some errors in 11.1.1.7.0.
    Please tell me some way to do this in all jdev versions.
    Bean obj = (Bean)RequestContext.getCurrentInstance.getExternalContext.getPageFlowScope(“obj”);
    Code for hide pop-up
    FacesContext context = FacesContext.getCurrentInstance();
    String popupId = obj.getPopUpBind().getClientId()
    ExtendedRenderKitService service = Service.getRenderKitService(FacesContext.getCurrentInstance(),
    ExtendedRenderKitService.class);
    String hidePopup = "var popupObj=AdfPage.PAGE.findComponent('" + popupId +
    "'); popupObj.hide();";
    service.addScript(FacesContext.getCurrentInstance(), hidePopup);
    Code to Show pop-up
    StringBuffer showPopup = new StringBuffer();
    showPopup.append("var hints = new Object();");
    showPopup.append("var popupObj=AdfPage.PAGE.findComponent('" +
    obj.getPopUpBind().getClientId() + "');popupObj.show(hints);");
    service.addScript(FacesContext.getCurrentInstance(), showPopup.toString());
    Code need to be added in jsff pop tag
    binding="#{pageFlowScope.bean.popUpBind}
    Variable need to be added in Bean.java
    private RichPopup popUpBind;

    Hari,
    Since you're using a non-public build of JDeveloper, you should be using a non-public forum.
    John

  • How to open Internet explorer from java

    how can one open internet explorer through java and also displays the desired webpage in it.

    p = r.exec(runie);Whenever you use exec on a Runtime object, you need to get an InputStream off the System.err output. If this InputStream is not absorbed in some way, then it can stop the process. The process may not reach its destined finish point. The Java Documentation does not inform you of this, though experience will give you some unanswered questions, such as 'Why does this process never reach the finish point'.
    James

  • How to open specific port using java program

    Hello,
    I want to open ,close port using java comm.plz help me how can i do it.is it possible
    by using java program.later i want to use that specific port to accept the server socket connection .plz
    help me.

    i try this java program.*but it get block in accept method*.tht mean i m not able to make connection with port.
    import java.sql.SQLException;
    import java.io.IOException;
    import java.net.ServerSocket;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    class MakeConn
         public final static int PORT = 7788;
    public static java.net.Socket clientSocket = null;
    public static java.io.PrintWriter pw = null; // socket output stream
    public static java.io.BufferedReader br = null;
    public static ServerSocket server_socket;
         public static void main(String[] args) throws SQLException
         try {
              server_socket = new ServerSocket(PORT);
    clientSocket = server_socket.accept();
    System.out.println("CLIENT>>>" + clientSocket);
         br = new java.io.BufferedReader(new java.io.InputStreamReader(clientSocket.getInputStream()));
    pw = new java.io.PrintWriter(clientSocket.getOutputStream(), true);
    String message = br.readLine().trim();
    System.out.println("message is"+message);
    pw.close(); // close everything
    br.close();
    clientSocket.close();
         catch (Exception ex) {
    ex.printStackTrace();
    }

  • To open "device manager" install Java SE 6 runtime error message on bouts

    Why does To open "device manager" install Java SE 6 runtime appear every time I boot up computer after installing upgrade to Yosemite 10.10 OS

    You must have some application called "device manager" which is set to run at startup. Do you know what it is?
    Go to System Preferences->Users and Groups, then select the "Login Items" tab and see what's there. Remove anything you don't recognize.
    If it's an application you know, and you want to run, then you're going to have to install Java on your machine. Honestly, I'd recommend against it; the application must be quite old.

  • Open start menu through java

    Is there any way to open start menu through java application just like when we open start menu by pressing the windows key on the keyboard.
    Waiting for urgent response
    Thanx
    Salman.

    Hi Salman,
    This is possible in 1.5 in a stright forward way. Following is the code
    import java.awt.GraphicsDevice;
    import java.awt.GraphicsEnvironment;
    import java.awt.Robot;
    import java.awt.event.KeyEvent;
    public class WindowsStartOpener
    public static void main(String[] argv)throws Exception
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    Robot robo = new Robot(gd);
    robo.setAutoDelay(100);
    robo.keyPress(KeyEvent.VK_WINDOWS);
    robo.keyRelease(KeyEvent.VK_WINDOWS);
    If you are using 1.4 version. You can try with the mouse event methods of Robo class.
    It is not possible with the versions earlier than 1.4. In this case you can write a C/C++ program and use JNI to invoke it.
    cheers,
    Sundar Lal Ch

  • Error while opening a dwg file :java.lang.NoSuchMethodException: Method

    Hello Experts,
    I tried to integrate WebCenter Content with Autovue ,the integration was good untill i get this error while trying to open a dwg file checked in Content Server using View in Autovue option in Actions :
    java.lang.NoSuchMethodException: Method fileOpen(com.cimmetry.core.SessionID, com.cimmetry.core.DocID, com.cimmetry.core.Authorization, <null>, java.lang.Boolean, <null>) not found in class com.cimmetry.jvueserver.VCETConnection
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ar.d(Unknown Source)
         at com.cimmetry.jvueserver.ar.a(Unknown Source)
         at com.cimmetry.jvueserver.ah.run(Unknown Source)
    Any suggestions would help me,
    Thanks in Advance
    Raj

    Hi Raj,
    The solution to this problem is posted in My Oracle Support:
    Error: "java.lang.NoSuchMethodException: Method fileOpen" when Trying to View Files Using AutoVue Integrated to Oracle Universal Content Management (UCM) (Doc ID 1341644.1).
    It has all the details, step by step.
    Jeff

Maybe you are looking for

  • Silverfast AI Studio crashing PSCS3 in Snow Leopard

    Photoshop CS3 has been working just fine in Snow Leopard, but I wondered what would happen when I fired up my scanner.  Finally tried it today.  I have used LaserSoft Silverfast, a pretty nice scanner driver, for years.  Silverfast attempts to load,

  • Redndering Issue

    Hi, I have just got Final Cut Express 4.0 today but i'm already having problems. I have a MacBook Pro, 2.16GHZ with 2GB of Ram, running Leopard, but for some reason, my video seems to want to render at every point? I know Final Cut is supposed to be

  • Large line to internal tables from  tab delimited file

    Dear All I am trying to upload the large file of tab delimited data into a SAP internal table. I am basically stuck with the fact that there are multiple lines and multiple columns in tab delimited file. There are around 300 columns which are tab del

  • Sync Outlook '11 with iPhone Calendar

    I want to sync my iPhone events that on my iPhone 4 right now to the Calendar in Outlook 2011 on my Mac but I don't want to replace anything else... like remove any events off my iPhone. But can I also do this wirelessly through cloud or something so

  • Line limit for JTextArea - Urgent

    Hi All, I would like to have 80 character limit for each line displayed in JTextArea. The linewrap along with wordwrap have been enabled for JTextArea but that solves a part of the problem. The no. of characters that can be entered per line depends o