faqts : Computers : Programming : Languages : Java

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 5 people (20%) answered Yes
Recently 1 of 5 people (20%) answered Yes

Entry

Java: Borland: JBuilder: X: How to create a 'Hello world' stand alone Windows application?

Jan 10th, 2004 22:01
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 11 January 2004 - 00:33 am --------------------

Java: Borland: JBuilder: X: How to create a 'Hello world' stand alone 
Windows application?

---

Steps: Overview:

 1. -possibly start JBuilder X

 2. -possibly close any projects which are open

     1. -select from menu option 'File'

     2. -select from list 'Close Projects...'

     3. -enable the checkbox for the projects you want to close

     4. -click button 'OK'

 3. -Open a new project

     1. -select from menu option 'File'

     2. -select from list 'New Project'

     3. -double click 'Application'

     4. -click button 'OK'

 4. -Supply some information in the wizard

     1. Name = e.g. ConsoleApplication1

     2. -click button 'Next'

     3. -click button 'Next'

     4. -click button 'Finish'

     5. -click button 'Next'

     6. -possibly enable checkbox

          'Create a runtime application'

     7. -click button 'Finish'

 5. -This will automatically generate some source code
     for you

--- cut here ---------------------------------------------------------

package consoleapplication1;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2004</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Frame1 extends JFrame {
  JPanel contentPane;
  BorderLayout borderLayout1 = new BorderLayout();

  //Construct the frame
  public Frame1() {
    enableEvents(AWTEvent.WINDOW_EVENT_MASK);
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }

  //Component initialization
  private void jbInit() throws Exception  {
    contentPane = (JPanel) this.getContentPane();
    contentPane.setLayout(borderLayout1);
    this.setSize(new Dimension(400, 300));
    this.setTitle("Frame Title");
  }

  //Overridden so we can exit when window is closed
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }
}

--- cut here ---------------------------------------------------------

 6. -click on the tab 'Design'

 7. -This will show you a form on which you can put
     some controls, like a button

     1. Select palette 'Swing'

     2. Double click on the 'button' [OK]

     3. Put your cursor on the form

     4. Click on the form

     5. That will put the button on your form

 8. -Fill in some code

     1. Double click on this button

     2. Fill in the text

          System.out.println( "Hello World from Borland JBuilder X" );

         - or similarly -

          jButton1.setText( "Hello World from Borland JBuilder X" );

 9. -Run your application

     1. Press <F9>

     - or -

     1. In the menu click on the green '>'
        icon

10. -Click on this button

11. -That should show e.g.

      Hello World from Borland JBuilder X

     in the messages window

12. -If you want to run this file outside your
     JBuilder, look e.g. at the path of this
     file (that is on the top of the form)

     1. Your java source files are by default located in your
        home directory, then directory 'jbproject'

      e.g.

     c:\documents and 
settings\administrator\jbproject\consoleapplication1
\src\consoleapplication1\frame1.java

     2. Your classes are located in the 'classes' directory there:

      e.g.

     c:\documents and 
settings\administrator\jbproject\consoleapplication1
\classes\consoleapplication1\frame1.class

13. So from the command line you could run your hello word program by 
running 'javaw.exe', e.g. type:

     1. Open an MSDOS box


     2. Type or paste the command (which you find and can copy to the
        clipboard
        (put e.g. your cursor inside in this 'Message' box in JBuilder,
         then press e.g. <CTRL><A>, then <CTRL><C>)

         C:\JBuilderX\jdk1.4\bin\javaw -classpath "C:\Documents and 
Settings\Administrator\jbproject\ConsoleApplication3
\classes;C:\JBuilderX\jdk1.4
\demo\jfc\Java2D\Java2Demo.jar;C:\JBuilderX\jdk1.4
\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\JBuilderX\jdk1.4
\jre\javaws\javaws.jar;C:\JBuilderX\jdk1.4
\jre\lib\charsets.jar;C:\JBuilderX\jdk1.4
\jre\lib\ext\dnsns.jar;C:\JBuilderX\jdk1.4
\jre\lib\ext\ldapsec.jar;C:\JBuilderX\jdk1.4
\jre\lib\ext\localedata.jar;C:\JBuilderX\jdk1.4
\jre\lib\ext\sunjce_provider.jar;C:\JBuilderX\jdk1.4
\jre\lib\im\indicim.jar;C:\JBuilderX\jdk1.4
\jre\lib\im\thaiim.jar;C:\JBuilderX\jdk1.4
\jre\lib\jce.jar;C:\JBuilderX\jdk1.4
\jre\lib\jsse.jar;C:\JBuilderX\jdk1.4
\jre\lib\plugin.jar;C:\JBuilderX\jdk1.4
\jre\lib\rt.jar;C:\JBuilderX\jdk1.4
\jre\lib\sunrsasign.jar;C:\JBuilderX\jdk1.4
\lib\dt.jar;C:\JBuilderX\jdk1.4
\lib\htmlconverter.jar;C:\JBuilderX\jdk1.4\lib\tools.jar"  
consoleapplication3.Application1

     ---

     Note:

      you will possibly have to adapt this file paths to the situation 
on your machine,
      but copy paste should do usually.

---
---

Internet: see also:

---

Java: Stand alone: Create: Simple: How to create a stand alone program 
that displays 'Hello World'?
http://www.faqts.com/knowledge_base/view.phtml/aid/24178

---

Java: Applet: Create: Simple: How to create a Java applet that 
displays 'Hello World'?
http://www.faqts.com/knowledge_base/view.phtml/aid/24144/fid/777

---

Java: Servlet: Create: Simple: How to create a Java servlet that 
displays 'Hello world'?
http://www.faqts.com/knowledge_base/view.phtml/aid/24154/fid/778

---

Java: Compile: Error: Exception in thread "main" 
java.lang.NoClassDefFoundError: HelloWorld
http://www.faqts.com/knowledge_base/view.phtml/aid/24300/fid/165

---

Java: Borland: JBuilder: X: Stand alone: Create: How to create 'Hello 
World' console program?
http://www.faqts.com/knowledge_base/view.phtml/aid/28228/fid/165

----------------------------------------------------------------------