Opening existing apps using java.awt.Desktop

I want to display my html file using existing applications such as IE. How I can do this?
My java version is 1.6 so the java.awt.Desktop is good for my reason?

        try {
            Desktop.getDesktop().open(new File("test.html"));
        } catch (IOException ex) {
            ex.printStackTrace();
        }

Similar Messages

  • Open URL in default Browser java.awt.Desktop was working...

    I downloaded Net Beans 6.5 with JavaFX 1 and now java.awt.Desktop isn't even an option for the imports, is there an alternative method to open URLs from my application?

    No, you aren't wrong.
    It's, and I mean this with all due respect, idiotic.
    I found some code on the net that does the same thing:
    http://www.centerkey.com/java/browser/
    Just one class, very simple.
    But I really would like java.awt.Desktop to work, I want the system tray integration stuff.
    Questions about getting Java 1.6 compatibility (the reason why the import doesn't work) go unanswered. It seems there is some hard coded -target 1.5 in some part of the javafx compiler. I can't figure out how to change it.

  • Open Folder by double click using java.awt

    Hello Guys,
    I have a problem. I m listing directory in List(java.awt). When i single click on directory it will open. But how i can double click on that directory then and then it will open otherwise not. By using JAVA.AWT.

    According to the documentation for java.awt.List "When an item is selected or
    deselected by the user, AWT sends an instance of ItemEvent to the list. When
    the user double-clicks on an item in a scrolling list, AWT sends an instance of
    ActionEvent to the list following the item event. AWT also generates an action
    event when the user presses the return key while an item in the list is selected."
    If your directories are "opening" (whatever that means) in response to a single
    click, that it because of how you have written your code. Change it so that action
    events rather than item events cause the opening to happen.

  • Open a webpage using Java

    Hi,
    I am trying to open a webpage in a browser using Java code. I have been reading the tutorials and came across some code that reads the webpage as a simple text using getPageContent etc. I don't need to read the page, I just need to open it.
    Can anyone please guide me, tell me which docs I should refer to etc.
    Thanks,
    M

    import java.awt.Desktop; //Java 1.6
    import java.io.IOException;
    import java.net.URI;
    import java.net.URISyntaxException;
    public class BrowseExample {
        public static void main(String[] args) throws IOException, URISyntaxException {
            URI uri = new URI("http://java.sun.com");
            Desktop.getDesktop().browse(uri);
    }

  • How to insert text in the middle of an existing textfile using java

    Hi,
    How to insert text in the middle of an existing textfile using java i/o streams??

    Mickie wrote:
    I shudn't delete the file...Then you will have the old file and the new file - do you want that?
    and I have to insert text not only at a single place ....got to do at many places in the text file!!then extrapolate on the procedure outlined in reply #1 .

  • 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

  • How to show error message using java.awt?

    How to show error message using java.awt?
    Which is the class corresponding to the JOptionPane?
    Or I need to use Frame ?

    No, JOptionPane is swing!
    You would have to create your own frame, put your message in it, then show it.

  • How to open Photoshop App CC on Mac desktop?

    Downloaded CC trial onto my Mac OS X 10.8.4 yesterday.  From there, how do I open the Photoshop app from the CC on my desktop?  There is not the option to click on the app from the app list.  I can click on the "More Information" below the app which takes me to the internet.  I need to open the app itself on my desktop. Thank you!

    Well, well, well.  For all of you newbies out there, on your apps page, just like an iPhone, there's a second
    "dot" indicating a second page.  And there is the app.  Right there.  Thanks folks.

  • 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();
    }

  • [svn] 4176: Make the team app use Java 1.5.

    Revision: 4176
    Author: [email protected]
    Date: 2008-11-24 13:42:21 -0800 (Mon, 24 Nov 2008)
    Log Message:
    Make the team app use Java 1.5.
    Modified Paths:
    blazeds/trunk/apps/team/build.xml

    Did you try this?
    http://docs.info.apple.com/article.html?artnum=302412
    Hope it helps ya!

  • Open a file using java......... how?

    hi all
    I have a prob with my code
    the problem is by using the FileChooser like
    file = fileChooser.getSelectedFile();
    I have the file name but how can i open that file e.g. if file is word document then that file should open in word , if that file is HTML file then open in IE , and other files as well.
    is there any way to open a file
    plz help me
    Thanx
    Regards
    Satinderjit

    veer ji, try this code on your pc if you can. Click the print button and see that happens. thanx yuvraj:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    //import com.sun.java.swing.*;
    import javax.swing.*;
    public class ComponentPrinterFrame
    extends JFrame
    implements Printable {
    public static void main(String[] args) {
    ComponentPrinterFrame cpf = new ComponentPrinterFrame();
    cpf.setVisible(true);
    public ComponentPrinterFrame() {
    super("ComponentPrinterFrame v1.0");
    createUI();
    protected void createUI() {
    JPanel panel = new JPanel();
    JButton printButton = new JButton("Print");
    panel.add(printButton);
    panel.add(new JList(new Object[] { "One", "Two", "Three" }));
    panel.add(new JButton("Push me"));
    panel.add(new JCheckBox("Chess", true));
    panel.add(new JComboBox(new Object[] { "Eins", "Zwei", "Drei" }));
    printButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent ae) {
    PrinterJob pj = PrinterJob.getPrinterJob();
    pj.setPrintable(ComponentPrinterFrame.this);
    if (pj.printDialog()) {
    try { pj.print(); }
    catch (PrinterException pe) {
    System.out.println(pe);
    setContentPane(panel);
    setSize(400, 400);
    // Center.
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension frameSize = getSize();
    int x = (screenSize.width - frameSize.width) / 2;
    int y = (screenSize.height - frameSize.height) / 2;
    setLocation(x, y);
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    dispose();
    System.exit(0);
    public int print(Graphics g, PageFormat pf, int pageIndex) {
    if (pageIndex != 0) return NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D)g;
    g2.translate(pf.getImageableX(), pf.getImageableY());
    getContentPane().paint(g2);
    return PAGE_EXISTS;

  • How need to take screen shot of the screen using java.awt.Robot from javafx

    1) I am displaying a Stage which is having an image and shapes in it and wanted to take the screen shot as and when i move the shape( which moves the stage ).
    I am trying to java.awt.Robot, but i am getting headless exception. I used
    @Override
    public void start(final Stage primaryStage) {
    // creating some images and shapes
    Platform.runLater(new Runnable() {
    @Override
    public void run() {
    // update();
    public void update() {
    if (stg.isShowing()) {
    ScreenCapture.capture(stg.getX() + 2, stg.getY() + 2, (int) boundsOfCircle.getBoundsInParent().getWidth(), (int) boundsOfCircle.getBoundsInParent().getHeight());
    magnifierImageView.setImage(new Image(SCREEN_SHOT_FILE));
    public static void capture(final double x, final double y, final int width, final int height) {
    EventQueue.invokeLater(new Runnable() {
    public void run() {
    try {
    System.out.println("x ="+x +" y = "+y +" width "+width +" height ="+height);
    Robot robot = new Robot();
    } catch (Exception e) {
    System.out.println("exception arised while taking the screen shot ");
    e.printStackTrace();
    The above code throws headless exception.
    2) The second issues is have a image & i am dividing the image into different rows and cols( images of same size ). This is i am doing using awt. and i wanted to load those different images into
    javafx images . I am facing the issues when i try to load the images into javafx.

    hi,
    click on print screen button in your keyboard.
    open a word document and do Ctrl V .
    *Reward points if it helped

  • 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

  • Can't find class when i use java.awt.Panel

    I got a Pocket PC with CE 3.0
    I made my first PJava application just a few hours ago. And it works fine. But when i introduce a Panel to improve the interface then application fails on the Pocket PC with the error message "could not find class application". When i remove the Panel it works fine again.
    I thought that java.awt.* is part of PJava. And even if not i should be able to introduce even a java.lang.* class to the PJava application if i use the JAR.
    Any suggestion?

    you should provide more detail about your deployment procedures.
    There are many ways to get this message. AWT in fact is part of pJava and works fine for most of us. So I assume the deployment is the problem. Have you checked the actual content of the JAR? Have you provided a path statement? How do you call your app (shortcut?)

  • Is there a way to open the mic using apple remote desktop

    Is there a way to open the mircophone channel using Apple Remote Desktop so I can listen on anything thats happening at my computer at home? If not is there another software that would work?
    Also is there a way to use apple's software to control and watch a PC?

    Is there a way to open the mircophone channel using Apple Remote Desktop so I can listen on anything thats happening at my computer at home? If not is there another software that would work?
    You would have to launch software that would accept audio from the microphone and transmit it to you in some fashion. ARD does not transmit audio itself. Another remote control solution such as Timbuktu might transmit audio, so you could look into that, perhaps.
    Also is there a way to use apple's software to control and watch a PC?
    You can install a VNC server on the PC and ARD can then take control of the system. It can be tricky to find a VNC system that will work with ARD, though, so search this forum for "VNC" for possible options. One of the applications that support Microsoft's remote desktop architecture such as their own Remote Desktop Connection Client for Mac or iTap Mobile RDP will probably work better, though.
    Regards.

Maybe you are looking for

  • Audio output doesn't work right. How to fix it?

    I plugged my earphones in and noticed that the left side was much louder than the right. I tried different earphones and and it works fine on my iphone so it definately is the plug in of my mac that now doesn't work properly anymore

  • Java app not working

    I have a MacBook Pro laptop and after I followed your advice I constantly get a message that reads, "Alert! This update requires Mac OS X version 10.6. My latest version is 10.8.2. It is too late for me to phone AppleCare. Community, please help with

  • Cisco anyconnect secure mobility client + caching

    Hi, We have recently implemented wifi at our location, all working fine with the below exception. we have cisco anyconnect secure mobility client installed on all laptops for VPN access. we are facing a problem as the vpn client is caching the creden

  • Can't open itunes because of album artwork

    Ok, so everytime that I try to open my itunes account, a little itunes setup assistant window pops up telling me that itunes can automatically download album artwork when I add songs to my library. It goes on in greater detail how to do it and then a

  • Why is video option GRAYED out?  Please help!

    I just bought an ipod video 60GB (iTunes 6) and I converted my own videos into the proper format and when I try to a add them to the library nothing happens. The video option tab is grayed out and I can't select any options. Can someone please help!