CANT COMPILE A THING - new to Java

I think I downloaded from this site correctly. So, I create a file, save it, open command prompt, go to the appropriate directory, enter the command line "javac Example1" (Example1 is both the class and file name). For some reason the javac command is not recognized. Help me please! I wanna program.

Here is comes again....:
My First Java Program (for Windows)
Follow these steps:
1. Download and install the Java 2 SDK
2. Make sure your path and classpath are set correctly
3. Type in your first program
4. Compile your first program
5. Run your first program
6. Read the Java tutorial
1. Download and install the Java 2 SDK
Go to the Java website and download the Java 2 SDK, Standard Edition:
http://java.sun.com/j2se/1.4.1/download.html
NOTE: Make sure you download the SDK (leftmost column) and not just the JRE. The JRE (Java Runtime Environment) only contains the stuff necessary to run Java programs, and not the compiler and other tools you need to develop Java programs.
After downloading, run the installation program to install the Java 2 SDK.
2. Make sure your path and classpath are set correctly
After installing, READ THE INSTALLATION NOTES! Lots of people get in trouble and are asking questions in the forums because they were too lazy to read and follow the installation notes. Especially, after installing the Java 2 SDK you need to add the 'bin' directory of the SDK to your PATH, otherwise you will get an error like "javac is not recognized as an internal or external command" or something similar.
If you've installed the Java 2 SDK in C:\j2sdk1.4.1_03, add C:\j2sdk1.4.1_03\bin to the PATH. If you don't know how to change environment variables in Windows, look at Microsoft's website (http://www.microsoft.com). The procedure is different for different versions of Windows.
If you are using a version of the Java 2 SDK older than 1.4, you need to add the current directory (".") to the CLASSPATH environment variable. CLASSPATH is where Java looks for *.class files (compiled Java classes). Since Java 1.4, Java looks in the current directory automatically if the CLASSPATH isn't set, so you don't need to add "." to the CLASSPATH. Again, the installation notes explain what CLASSPATH is and how you should set it.
3. Type in your first program
Start Notepad and type in your first program:
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello World");
}NOTE: Java is case-sensitive. Be careful to type in the program exactly as shown above. Don't type "Helloworld" or "helloworld" or anything else.
Save the file somewhere in a file called "HelloWorld.java". NOTE: Again, the case must be correct. Even though Windows is case-insensitive for filenames, the case must be correct, because Java is case-sensitive. Also watch out that Notepad doesn't append ".txt" to the filename (so that you end up with a file called "HelloWorld.java.txt"). To make things worse, Windows Explorer hides file extensions by default so you don't even see that the file is actually called "HelloWorld.java.txt" instead of "HelloWorld.java".
4. Compile your first program
Open a command prompt, CD to the directory that contains your source file and type:
javac HelloWorld.java
NOTE: Again, the case must be exactly right.
If all goes well, you'll not get any error messages and a file "HelloWorld.class" is generated.
5. Run your first program
To run your program, type:
java HelloWorld
NOTE: Don't type "HelloWorld.class". You are specifying the class name here, not the filename. Ofcourse, the case is important again.
6. Read the Java tutorial
Go to the Java website and follow The Java Tutorial:
http://java.sun.com/docs/books/tutorial/
The chapter "Your First Cup of Java" also explains in detail how to start with Java.
Jesper

Similar Messages

  • New to Java cant get it to compile in msDOS

    Using SDK java 2 version 1.4.0. Checked my personal Computer folder types.
    In folders in windows 98 do java file types open with javac.exe or java.exe? Tried both. When I try to compile a simple tutorial HelloWorldApp.java , it gives me a message that javac cant read it. The path is OK on MS DOS since it recognizes the javac command. I should be having no problems with tutorial. Did I mess up the links to the class and java file types ?. Microsoft tech support fixed a problem when I opened some demo files into the wrong programs and it was permanent.Then I tried to reset the right exe files to go with the file types but I am not sure. I have tried re downloading the software several times. Should I buy a sun software or are these downloads bad?

    use javac to compile java programs.
    e.g.
    javac HelloWorld.java
    use java to run compiled code (class files)
    java HelloWorld
    (Don't include the extension .class when using the java command)

  • New to Java - cannot get computer to compile?

    Hi
    I'm from UK, although I've used one for ages I am new to computing itself and very new to programming - in fact I haven't started yet because I cannot get my JDK to work!! I have downloaded it successfully, it is installed and I have verified the version from athe command prompt. I have written a programme as detailed in my Programming with Java book, and saved it with a java file extension and I am sure it is correct. But when I try to compile mit I get "'javac' is not recognised as an internal or external command, operable program or batch file"
    My book has no further advice on what to do - can anyone on this site offer me any help please.
    Thanks

    Make sure the path to the javac.exe is specified in the environment CLASSPATH, otherwise you'll have to instruct your command window to point to the java/bin directory every time you wish to compile something... Not fun... :P
    After that, just follow the instructions pointed at the tutorial...
    Check out the installation doc at http://java.sun.com/j2se/1.5.0/install-windows.html , specifically, the heading: 5. Update the PATH variable (Optional)
    If you're new to java, I recommend getting an IDE to simplify things: www.jcreator.com is nice and free, try it out... ;)

  • Compiling message "cannot read" (new to java)

    Sorry about yet another question on compiling. I'm new to java. I've read alot of the threads on this, but my HelloJava.java won't compile.
    I'm working on w2k. I've set my path to
    %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;c:\j2sdk1.4.0\bin
    using the environment variables in the system properties box.
    This seems to work fine.
    but I keep getting the "cannot read" when compiling.
    I've created a classpath variable in the environment variables
    CLASSPATH = .;C:\src
    and my java file is definately .java not .java.txt and it's in the src folder on my c drive.
    Do I need to set classpath? Also I've put my HelloJava.java file in the same folder as my javac and it still won't compile. What am I doing wrong?
    By the way, the HelloJava file came from the book "Learning Java".
    thanks in advance.

    OK -
    If you place your .java files in C:\src, to compile you must either
    1. Go to (change the current directory to, using cd command) c:\src and then enter "javac ...."
    or
    2 From any directory enter "javac C:\src\...."
    Classpath is used by javac and java, but not in this way.
    Read here for the full story:
    The Path is a set of pointers that Windows uses to locate programs that you execute, like javac.exe and java.exe. This setting is explained here:
    http://java.sun.com/j2se/1.4/install-windows.html
    Scroll down to: 5. Update the PATH variable
    The CLASSPATH is another set of pointers that is used by Java to find the files that you create and want compiled and/or run. This setting is explained here:
    Setting the Classpath:
    http://java.sun.com/j2se/1.4/docs/tooldocs/windows/classpath.html
    [NOTE: always start your classpath with ".;" which means the current directory. See my classpath, below]
    How Classes are Found:
    http://java.sun.com/j2se/1.4/docs/tooldocs/findingclasses.html

  • Hi..i am trying to login i message but i cant access ,it thing i forgot my password number, please i need help,how i can reset new password number. please i need help.

    hi..i am trying to login i message but i cant access ,it thing i forgot my password number, please i need help,how i can reset new password number. please i need help.

    Go here.
    Good luck,
    Clinton

  • My iphone recently fell and now my screen is damaged,i cant see a thing but it works, if i backup my data to iclouds would i be able to get back all my messages in like whatsapp when i get a new iphone?

    i have an iphone 4s,  it recently fell now the screen is damaged i cant see a thing its not cracked, if i back up to icloud would i be able to get back my messages from whatsapps

    did you turned on keychain and documents turned on if that is on you can get back your chat history....

  • New to Java and need help with this program..please!

    I'd really appreciate any helpful comments about this program assignment that I have to turn in a week from Friday. I'm taking a class one night a week and completely new to Java. I'd ask my professor for help, but we can't call him during the week and he never answers e-mails. He didn't tell us how to call from other classes yet, and I just can't get the darn thing to do what I want it to do!
    The assignment requirements are:
    1. Change a card game application that draws two cards
    and the higher card wins, to a Blackjack application
    2. Include a new class called Hand
    3. The Hand class should record the number of draws
    4. The application should prompt for a number of draws
    5. The game is played against the Dealer
    6. The dealer always draws a card if the dealer's hand total is <= 17
    7. Prompt the player after each hand if he wants to quit
    8. Display the total games won by the dealer and total and the total games wond by the player after each hand
    9. Display all of the dealer's and player's cards at the
    end of each hand
    10. Player has the option of drawing an additional card after the first two cards
    11. The Ace can have a value of 11 or 1
    (Even though it's not called for in the requirements, I would like to be able to let the Ace have a value of 1 or an 11)
    The following is my code with some comments about a few things that are driving me nuts:
    import java.util.*;
    import javax.swing.*;
    import java.text.*;
    public class CardDeck
    public CardDeck()
    deck = new Card[52];
    fill();
    shuffle();
    public void fill()
    int i;
    int j;
    for (i = 1; i <= 13; i++)
    for (j = 1; j <= 4; j++)
    deck[4 * (i - 1) + j - 1] = new Card(i, j);
    cards = 52;
    public void shuffle()
    int next;
    for (next = 0; next < cards - 1; next++)
    int rand = (int)(Math.random()*(next+1));
    Card temp = deck[next];
    deck[next] = deck[rand];
    deck[rand] = temp;
    public final Card draw()
    if (cards == 0)
    return null;
    cards--;
    return deck[cards];
    public int changeValue()
    int val = 0;
    boolean ace = false;
    int cds;
    for (int i = 0; i < cards; i++)
    if (cardValue > 10)
    cardValue = 10;
    if (cardValue ==1)     {
    ace = true;
    val = val + cardValue;
    if ( ace = true && val + 10 <= 21 )
    val = val + 10;
    return val;
    public static void main(String[] args)
    CardDeck d = new CardDeck();
    int x = 3;
    int i;
    int wins = 1;
    int playerTotal = 1;
    do {
    Card dealer = (d.draw());
    /**I've tried everything I can think of to call the ChangeValue() method after I draw the card, but nothing is working for me.**/
    System.out.println("Dealer draws: " + dealer);
    do {
    dealer = (d.draw());
    System.out.println(" " + dealer);
    }while (dealer.rank() <= 17);
    Card mine = d.draw();
    System.out.println("\t\t\t\t Player draws: "
    + mine);
    mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
    do{
    String input = JOptionPane.showInputDialog
    ("Would you like a card? ");
    if(input.equalsIgnoreCase("yes"))
         mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
         playerTotal++;
         else if(input.equalsIgnoreCase("no"))
    System.out.println("\t\t\t\t Player stands");
         else
    System.out.println("\t\tInvalid input.
    Please try again.");
    I don't know how to go about making and calling a method or class that will combine the total cards delt to the player and the total cards delt to the dealer. The rank() method only seems to give me the last cards drawn to compare with when I try to do the tests.**/
    if ((dealer.rank() > mine.rank())
    && (dealer.rank() <= 21)
    || (mine.rank() > 21)
    && (dealer.rank() < 22)
    || ((dealer.rank() == 21)
    && (mine.rank() == 21))
    || ((mine.rank() > 21)
    && (dealer.rank() <= 21)))
    System.out.println("Dealer wins");
    wins++;
         else
    System.out.println("I win!");
    break;
    } while (playerTotal <= 1);
    String stop = JOptionPane.showInputDialog
    ("Would you like to play again? ");
    if (stop.equalsIgnoreCase("no"))
    break;
    if (rounds == 5)
    System.out.println("Player wins " +
    (CardDeck.rounds - wins) + "rounds");
    } while (rounds <= 5);
    private Card[] deck;
    private int cards;
    public static int rounds = 1;
    public int cardValue;
    /**When I try to compile this nested class, I get an error message saying I need a brace here and at the end of the program. I don't know if any of this code would work because I've tried adding braces and still can't compile it.**/
    class Hand()
    static int r = 1;
    public Hand() { CardDeck.rounds = r; }
    public int getRounds() { return r++; }
    final class Card
    public static final int ACE = 1;
    public static final int JACK = 11;
    public static final int QUEEN = 12;
    public static final int KING = 13;
    public static final int CLUBS = 1;
    public static final int DIAMONDS = 2;
    public static final int HEARTS = 3;
    public static final int SPADES = 4;
    public Card(int v, int s)
    value = v;
    suit = s;
    public int getValue() { return value; }
    public int getSuit() { return suit;  }
    public int rank()
    if (value == 1)
    return 4 * 13 + suit;
    else
    return 4 * (value - 1) + suit;
    /**This works, but I'm confused. How is this method called? Does it call itself?**/
    public String toString()
    String v;
    String s;
    if (value == ACE)
    v = "Ace";
    else if (value == JACK)
    v = "Jack";
    else if (value == QUEEN)
    v = "Queen";
    else if (value == KING)
    v = "King";
    else
    v = String.valueOf(value);
    if (suit == DIAMONDS)
    s = "Diamonds";
    else if (suit == HEARTS)
    s = "Hearts";
    else if (suit == SPADES)
    s = "Spades";
    else
    s = "Clubs";
    return v + " of " + s;
    private int value; //Value is an integer, so how can a
    private int suit; //string be assigned to an integer?
    }

    Thank you so much for offering to help me with this Jamie! When I tried to call change value using:
    Card dealer = (d.changeValue());
    I get an error message saying:
    Incompatible types found: int
    required: Card
    I had my weekly class last night and the professor cleared up a few things for me, but I've not had time to make all of the necessary changes. I did find out how toString worked, so that's one question out of the way, and he gave us a lot of information for adding another class to generate random numbers.
    Again, thank you so much. I really want to learn this but I'm feeling so stupid right now. Any help you can give me about the above error message would be appreciated.

  • New to Java(TM) ME Platform SDK 3.0 how to open multiple emulators?

    Hi im new to Java Mobile Phone apps.
    I want to make a bluetooth game and theres a great bluetooth example in the package but i just cant find anywhere i can open 2 or more emulators.
    The compiler does'nt allow multiple instances either, Havent found a setting to change that either.
    Please help thank you.

    ooo apperently you have to "copy" the project and then change the emulator settings for the project to use a diffrent emulator shell. also you have to fix all build errors.

  • Im new to java and hope somebody can help me with my question

    Hi!
    Im quite new to java and I just have some simple questions..
    can someone please tell what kinds of error are considered as language violation for java? where can I find more info about these errors?
    can someone give me a simple example on a kind of error that cannot be caught in both compilation and runtime? I hope someone can help me out. Thanks in advance!!

    knightz211 wrote:
    Im just asking about errors that might go against the language definition but cant be detected.. If it "goes against the language defintion," it will be detected by the compiler. That's half of the compiler's job is to tell you what you've done that violates the language spec.
    because it confuses me when they say that such errors might occur so I just want to know what might these errors be.. sorry for that..Who's "they"? What exactly* did "they" say about "such errors"? It sounds to me like you're just confused, and you think there's something mysterious and inexplicable going on but you don't know what and don't even know what you're asking.
    I would suggest not worrying about hypothetical problems that you can't even put into words and focussing on learning Java. Along the way, if you encounter real, specific, actual problems, ask about them, and you'll probably get answers about the problems themselves and the language or theory behind them.

  • New to Java RMI

    I am having problems with the following code that I am currently trying to understand RMI from Java head First, the following are meant to be part of an universal browser that the browser downloads and displays interactive Java GUIs. Can someone explain what I am doing wrong as I am still new to Java please?
    import java.awt.*;
    import javax.swing.*;
    import java.rmi.*;
    import java.awt.event.*;
    public class ServiceBrowser {
       JPanel mainPanel;
       JComboBox serviceList;
       ServiceServer server;
       public void buildGUI() {
          JFrame frame = new JFrame("RMI Browser");
          mainPanel = new JPanel();
          frame.getContentPane().add(BorderLayout.CENTER, mainPanel);
          Object[] services = getServicesList();
          serviceList = new JComboBox(services);
          frame.getContentPane().add(BorderLayout.NORTH, serviceList);
          serviceList.addActionListener(new MyListListener());    
          frame.setSize(500,500);
          frame.setVisible(true);
       void loadService(Object serviceSelection) {
           try {
              Service svc = server.getService(serviceSelection);
              mainPanel.removeAll();
              mainPanel.add(svc.getGuiPanel());
              mainPanel.validate();
              mainPanel.repaint();
            } catch(Exception ex) {
               ex.printStackTrace();
       Object[] getServicesList() {
          Object obj = null;
          Object[] services = null;
          try {
              obj = Naming.lookup("rmi://127.0.0.1/ServiceServer");   
         catch(Exception ex) {
           ex.printStackTrace();
         server = (ServiceServer) obj;
          try {
            services = server.getServiceList();
          } catch(Exception ex) {
             ex.printStackTrace();
         return services;
       class MyListListener implements ActionListener {
          public void actionPerformed(ActionEvent ev) {
              // do things to get the selected service
              Object selection =  serviceList.getSelectedItem();
              loadService(selection);
      public static void main(String[] args) {
         new ServiceBrowser().buildGUI();
    }I am able to compile the code but come up with the following error messages at runtime
    java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
         java.net.ConnectException: Connection refused
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
         at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
         at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
         at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
         at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
         at java.rmi.Naming.lookup(Naming.java:84)
         at ServiceBrowser.getServicesList(ServiceBrowser.java:53)
         at ServiceBrowser.buildGUI(ServiceBrowser.java:19)
         at ServiceBrowser.main(ServiceBrowser.java:82)
    Caused by: java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
         at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:432)
         at java.net.Socket.connect(Socket.java:529)
         at java.net.Socket.connect(Socket.java:478)
         at java.net.Socket.<init>(Socket.java:375)
         at java.net.Socket.<init>(Socket.java:189)
         at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
         at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
         at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
         ... 8 more
    java.lang.NullPointerException
         at ServiceBrowser.getServicesList(ServiceBrowser.java:64)
         at ServiceBrowser.buildGUI(ServiceBrowser.java:19)
         at ServiceBrowser.main(ServiceBrowser.java:82)
    Exception in thread "main" java.lang.NullPointerException
         at javax.swing.DefaultComboBoxModel.<init>(DefaultComboBoxModel.java:53)
         at javax.swing.JComboBox.<init>(JComboBox.java:175)
         at ServiceBrowser.buildGUI(ServiceBrowser.java:21)
         at ServiceBrowser.main(ServiceBrowser.java:82)
    The code for the remote implementation compile and runs, but the other code for services compiles but come back with the following error message at runtime:
    Exception in thread "main" java.lang.NoSuchMethodError: main
    I have included one of the services code below this happens with:
    import javax.swing.*;
    import java.awt.event.*;
    import java.io.*;
    public class DiceService implements Service {
        JLabel label;
        JComboBox numOfDice;
        public JPanel getGuiPanel() {
           JPanel panel = new JPanel();
           JButton button = new JButton("Roll 'em!");
           String[] choices = {"1", "2", "3", "4", "5"};
           numOfDice = new JComboBox(choices);
           label = new JLabel("dice values here");
           button.addActionListener(new RollEmListener());
           panel.add(numOfDice);
           panel.add(button);
           panel.add(label);
           return panel;
       public class RollEmListener implements ActionListener {
          public void actionPerformed(ActionEvent ev) {
             // roll the dice
             String diceOutput = "";
             String selection = (String)  numOfDice.getSelectedItem();
             int numOfDiceToRoll = Integer.parseInt(selection);
             for (int i = 0; i < numOfDiceToRoll; i++) {
                int r = (int) ((Math.random() * 6) + 1);
                diceOutput += (" " + r);
            label.setText(diceOutput);
    }

    how I do get suitable server running, can I not test the code on a local ip address first, i have included the remote implementation code below, can you advise how I can resolve this please or point me in the right direction?
    import java.rmi.*;
    import java.util.*;
    import java.rmi.server.*;
    public class ServiceServerImpl extends UnicastRemoteObject implements ServiceServer  {
        HashMap<String, Service> serviceList;
        public ServiceServerImpl() throws RemoteException {
           // start and set up services
           setUpServices();
       private void setUpServices() {
           serviceList = new HashMap<String, Service>();
           serviceList.put("Dice Rolling Service", new DiceService()); 
           serviceList.put("Day of the Week Service", new DayOfTheWeekService()); 
           serviceList.put("Visual Music Service", new MiniMusicService());  
        public Object[] getServiceList() {
           System.out.println("in remote");
           return serviceList.keySet().toArray();
        public Service getService(Object serviceKey) throws RemoteException {       
           Service theService = (Service) serviceList.get(serviceKey);      
           return theService;
        public static void main (String[] args) {
           try {
             Naming.rebind("ServiceServer", new ServiceServerImpl());
            } catch(Exception ex) { }
            System.out.println("Remote service is running");
    }

  • Cant compile client prg

    Hello all,
    am using weblogic8.1, first of all I would like to know do we need to give a name("Advisor") in JNDI in weblogic, as its mentioned in HFEJB page52 for RI Server. if you say that we have give the JNDI name in weblogic,
    where do we ned to give?
    this is place where I stand now...
    AdviceBean.ejb
    package headfirst;
    import javax.ejb.*;
    import weblogic.ejb.*;
    import headfirst.*;
    * @ejbgen:session
    * ejb-name = "Advice"
    * @ejbgen:jndi-name
    * remote = "ejb.AdviceRemoteHome"
    * @ejbgen:file-generation remote-class = "true" remote-class-name = "AdviceRemote" remote-home = "true" remote-home-name = "AdviceHome" local-class = "false" local-class-name = "AdviceLocal" local-home = "false" local-home-name = "AdviceLocalHome"
    public class AdviceBean implements SessionBean {
    // OK, not very exciting advice! You should come up with something better...
    private String[] adviceStrings = {"test", "test1", "test2", "test3"};
    public void ejbActivate() {
    System.out.println("ejb activate");
    public void ejbPassivate() {
    System.out.println("ejb passivate");
    public void ejbRemove() {
    System.out.println("ejb remove");
    public void setSessionContext(SessionContext ctx) {
    System.out.println("session context");
    // this business method name is changed from the book, because
    // there of a bug on some versions of the J2EE RI
    public String getMessage() {
    System.out.println("in get advice");
    int random = (int) (Math.random() * adviceStrings.length);
    return adviceStrings[random];
    public void ejbCreate() {
    System.out.println("in ejb create");
    AdviceClient.java
    package headfirst;
    import javax.naming.*;
    import java.rmi.*;
    import javax.rmi.*;
    import headfirst.*;
    import javax.ejb.*;
    // not all of these imports are used in this code...
    // but in a real client you'd probably need at least
    // java.rmi.RemoteException and javax.ejb.CreateException
    public class AdviceClient {
    public static void main(String[] args) {
    new AdviceClient().go();
    public void go() {
    try {
    Context ic = new InitialContext();
    Object o = ic.lookup("Advisor"); // replace with YOUR JNDI name for the bean
    AdviceHome home = (AdviceHome) PortableRemoteObject.narrow(o, AdviceHome.class);
    Advice advisor = home.create();
    System.out.println(advisor.getMessage());
    } catch (Exception ex) {
    ex.printStackTrace();
    I cant able to build with this file D:\Weblogic\user_projects\AdviceApp\AdviceApp\headfirst\AdviceClient.java
    So I remove this client file for a while to build the .jar
    after removing this client file, I can able to build. Done, now i got the AdviceApp.jar. again I brought back the client file to the same place..
    I tried from cmd
    D:\Weblogic\user_projects\AdviceApp\AdviceApp\headfirst>javac -classpath "C:\Program Files\j2sdkee1.3.1\lib\j2ee.jar";"D:\Weblogic\user_projects\AdviceApp\Advic
    eApp\AdviceApp.jar" AdviceClient.java
    AdviceClient.java:28: cannot resolve symbol
    symbol : class Advice
    location: class headfirst.AdviceClient
    Advice advisor = home.create();
    ^
    1 error
    Please tel me how to get rid of this issue...

    1008783 wrote:
    Hi
    I cant compile and excute this function
    /* Where can I declare or execute this fields */
    CREATE TYPE typ_get_brandings as object(
    BRANDING_CODE varchar2(200),
    NAME_DESC varchar2(200)
    /* Where can I declare or execute this fields */
    CREATE TYPE tab_get_brandings is table of typ_get_brandings
    CREATE FUNCTION get_brandings
    RETURN tab_get_brandings
    IS
    l_brandings tab_get_brandings;
    BEGIN
    SELECT typ_get_brandings( b.BRANDING_CODE,C.NAME_DESC)
    into l_brandings
    from development.brandings b,godot.company c
    where b.company_id = c.company_id
    return l_brandings;
    EXCEPTION
    WHEN OTHERS THEN
    CORPORATE.COMMON.EXCEPTION_LOG( 'DEVELOPMENT.BRANDING_ADMIN.GET_BRANDING', SQLCODE, SQLERRM, null, FALSE );
    return SQLCODE;
    END;
    Please helpHi ,
    Why you wanna create object ? any specific requirement?
    create table plch_test(id number,name varchar2(30));
    insert into plch_test values(1,'ram');
    insert into plch_test values(2,'abhi');
    insert into plch_test values(3,'aksi');
    CREATE OR REPLACE FUNCTION PLCH_FNC(p_id IN plch_test.id%TYPE)
    RETURN plch_test%ROWTYPE
    IS
    rec_plch_test plch_test%ROWTYPE;
    BEGIN
    SELECT id,name
    INTO rec_plch_test
    FROM plch_test
    WHERE id=p_id;
    EXCEPTION WHEN NO_DATA_FOUND THEN
    rec_plch_test:=null;
    RETURN rec_plch_test;
    END;Call the function
    SQL> set serveroutput on
    SQL> DECLARE
      2  rec_plch plch_test%ROWTYPE;
      3  BEGIN
      4  rec_plch:=PLCH_FNC(1);
      5  dbms_output.put_line('ID'||' '||rec_plch.id||' '||'NAME'||' '||rec_plch.name);
      6  END;
      7  .
    SQL> /
    ID 1 NAME ram
    PL/SQL procedure successfully completed.
    SQL> DECLARE
      2  rec_plch plch_test%ROWTYPE;
      3  BEGIN
      4  rec_plch:=PLCH_FNC(2);
      5  dbms_output.put_line('ID'||' '||rec_plch.id||' '||'NAME'||' '||rec_plch.name);
      6  END;
      7  .
    SQL> /
    ID 2 NAME abhi
    PL/SQL procedure successfully completed.
    SQL> Regards,
    Achyut Kotekal
    Edited by: Achyut K on Jun 6, 2013 12:03 AM

  • Hello, I am new to java and I am trying to something cool

    Hello I am new to Java and I am trying to do something cool. I have written some code and it compiles nicely. Basically what I am trying to do is use ActionListeners with JTextArea to change the size of a rectangle thing.
    Here is my code. The problem is that when I push the submit button nothing happens. Any help you could give would be greatly appreciated.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    class SecondGate extends JFrame implements ActionListener {
         float sxd = 190f;
         float dps = 190f;
         JTextArea Long = new JTextArea(1,3);
         JTextArea Short = new JTextArea(1,3);
         JLabel one = new JLabel("width");
         JLabel two = new JLabel ("Height");
         JButton Submit = new JButton("Submit");
    public SecondGate() {
    super("Draw a Square");
    setSize(500, 500);
         Submit.addActionListener(this);
         setLayout(new BorderLayout());
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         String Width = Float.toString(sxd);
         String Height = Float.toString(dps);
         Rect sf = new Rect(Width, Height);
         JPanel pane = new JPanel();
         pane.add(one);
         pane.add(Long);
         pane.add(two);
         pane.add(Short);
         pane.add(Submit);
         add(pane, BorderLayout.EAST);
         add(sf,BorderLayout.CENTER);
    setVisible(true);
         public void actionPerformed(ActionEvent evt) {
    Object source = evt.getSource();
    if (source == Submit) {
              sxd = Float.parseFloat(Long.getText());
              dps = Float.parseFloat(Short.getText());
         repaint();
         public static void main(String[] arguments) {
    SecondGate frame = new SecondGate();
    class Rect extends JPanel {
         String Width;
         String Height;
    public Rect(String Width, String Height) {
    super();
    this.Width = Width;
    this.Height = Height;
    public void paintComponent(Graphics comp) {
    super.paintComponent(comp);
    Graphics2D comp2D = (Graphics2D)comp;
    comp2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
         BasicStroke pen = new BasicStroke(5F, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
    comp2D.setStroke(pen);
         comp2D.setColor(Color.blue);
         BasicStroke pen2 = new BasicStroke();
    comp2D.setStroke(pen2);
    Ellipse2D.Float e1 = new Ellipse2D.Float(235, 140, Float.valueOf(Width), Float.valueOf(Height));
    comp2D.fill(e1);
         GeneralPath fl = new GeneralPath();
         fl.moveTo(100F, 90F);
         fl.lineTo((Float.valueOf(Width) + 100F),90F);
         fl.lineTo((Float.valueOf(Width) + 100F),(Float.valueOf(Height) + 90F));
         fl.lineTo(100F,(Float.valueOf(Height) + 90F));
         fl.closePath();
         comp2D.fill(fl);
         }

    I got it to work. You were right about the method and references. Thank you
    Here is the working code for anyone who is interested in how to do this.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    class SecondGate extends JFrame implements ActionListener {
    float sxd = 190f;
    float dps = 190f;
    JTextArea Long = new JTextArea(1,3);
    JTextArea Short = new JTextArea(1,3);
    JLabel one = new JLabel("width");
    JLabel two = new JLabel ("Height");
    JButton Submit = new JButton("Submit");
    String Width = Float.toString(sxd);
    String Height = Float.toString(dps);
    Rect sf = new Rect(Width, Height);
         public SecondGate() {
              super("Draw a Square");
              setSize(500, 500);
              Submit.addActionListener(this);
              setLayout(new BorderLayout());
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel pane = new JPanel();
              pane.add(one);
              pane.add(Long);
              pane.add(two);
              pane.add(Short);
              pane.add(Submit);
              add(pane, BorderLayout.EAST);
              add(sf,BorderLayout.CENTER);
              setVisible(true);
         public void actionPerformed(ActionEvent evt) {
              Object source = evt.getSource();
              if (source == Submit) {
              String Width = Long.getText();
              String Height = Short.getText();          
              sf.Width(Width);
              sf.Height(Height);
                   repaint();
         public static void main(String[] arguments) {
              SecondGate frame = new SecondGate();
         class Rect extends JPanel {
              String Width;
              String Height;
         public Rect(String Width, String Height) {
              super();
              this.Width = Width;
              this.Height = Height;
         String Width (String Width){
              this.Width = Width;
              return this.Width;
         String Height (String Height) {
              this.Height = Height;
              return Height;
         public void paintComponent(Graphics comp) {
              super.paintComponent(comp);
              Graphics2D comp2D = (Graphics2D)comp;
              comp2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
              BasicStroke pen = new BasicStroke(5F, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND);
              comp2D.setStroke(pen);
              comp2D.setColor(Color.blue);
              BasicStroke pen2 = new BasicStroke();
              comp2D.setStroke(pen2);
              Ellipse2D.Float e1 = new Ellipse2D.Float(235, 140, Float.valueOf(Width), Float.valueOf(Height));
              comp2D.fill(e1);
              GeneralPath fl = new GeneralPath();
              fl.moveTo(100F, 90F);
              fl.lineTo((Float.valueOf(Width) + 100F),90F);
              fl.lineTo((Float.valueOf(Width) + 100F),(Float.valueOf(Height) + 90F));
              fl.lineTo(100F,(Float.valueOf(Height) + 90F));
              fl.closePath();
              comp2D.fill(fl);
              }

  • What's new in Java 4

    Anybody can quickly explain the things are added in Java 4 newly.
    Thnx in advance.

    Nothing's new in Java 4 because there is no Java 4.
    Maybe you mean Java 5?
    Or maybe you mean Java 1.4?
    In either case, either the download page for that version, or the installation, should have release notes that answer your question.
    In fact, here they are for Java 5:
    http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html

  • New to java and having issues trying to modify sample code.

    i was trying to edit the following code to add about 10+ more labels and textfields and save the information to the contacts.dat in the code. it currently displays all the fields i entered, but it only saves the first 7 fields information?? not sure why. also i was trying to just line the fields up using a flowlayout but it just errors. anyone have any suggestions?
    <source code below this line>
    ====================START OF CODE ======================
    // cm.java
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    // =========================================================
    // Class: cm
    // This class drives the contact manager. It contains the
    // main method which gets called as soon as this application
    // begins to run.
    // =========================================================
    class cm extends Frame implements ActionListener
    // Container of contact objects (one object per business
    // contact).
    private Vector contacts = new Vector (100);
    // List of names component. (Must specify java.awt in
    // front of List to distinguish the List class in the
    // java.awt package from the List class in the java.util
    // package.)
    private java.awt.List names = new java.awt.List ();
    // delete and edit button components.
    private Button delete;
    private Button edit;
    // Default constructor.
    public cm ()
    // Assign Contact Manager to title bar of frame window.
    super ("Customer Manager Version 0.001 BY Pebkac");
    // Add a listener that responds to window closing
    // events. When this event occurs (by clicking on the
    // close box in the title bar), save contacts and exit.
    addWindowListener (new WindowAdapter ()
    public void windowClosing
    (WindowEvent e)
    saveContacts ();
    System.exit (0);
    // Place an empty label in the north part of the frame
    // window. This is done to correct an AWT positioning
    // problem. (One thing that you'll come to realize as
    // you work with the AWT is that there are lots of bugs.)
    Label l = new Label ();
    add ("North", l);
    // Place the names component in the center part of the
    // frame window.
    add ("Center", names);
    // Create a panel object to hold four buttons.
    Panel p = new Panel ();
    Button b;
    // Add an add button to the Panel object and register
    // the current cm object as a listener for button events.
    p.add (b = new Button ("add"));
    b.addActionListener (this);
    // Add a delete button to the Panel object and register
    // the current cm object as a listener for button events.
    p.add (delete = new Button ("delete"));
    delete.addActionListener (this);
    // The delete button should be disabled until there is at
    // least one contact to delete.
    delete.setEnabled (false);
    // Add an edit button to the Panel object and register
    // the current cm object as a listener for button events.
    p.add (edit = new Button ("edit"));
    edit.addActionListener (this);
    // The edit button should be disabled until there is at
    // least one contact to edit.
    edit.setEnabled (false);
    // Add a quit button to the Panel object and register
    // the current cm object as a listener for button events.
    p.add (b = new Button ("quit"));
    b.addActionListener (this);
    // Add the panel object to the frame window container.
    add ("South", p);
    // Set the background of the frame window container to
    // pink (to give a pleasing effect).
    setBackground (Color.pink);
    // Set the size of the frame window container to 400
    // pixels horizontally by 200 pixels vertically.
    setSize (400, 200);
    // Do not allow the user to resize the frame window.
    setResizable (false);
    // Load all contacts.
    loadContacts ();
    // Make sure that the frame window is visible.
    setVisible (true);
    public void actionPerformed (ActionEvent e)
    if (e.getActionCommand ().equals ("delete"))
    delete ();
    else
    if (e.getActionCommand ().equals ("quit"))
    saveContacts ();
    System.exit (0);
    else
    if (e.getActionCommand ().equals ("add"))
    add ();
    else
    edit ();
    public Insets getInsets ()
    // Return an Insets object that describes the number of
    // pixels to reserve as a border around the edges of the
    // frame window.
    return new Insets (10, 10, 10, 10);
    public static void main (String [] args)
    // Create a new cm object and let it do its thing.
    new cm ();
    private void delete ()
    // Obtain index of selected contact item from the names
    // component.
    int index = names.getSelectedIndex ();
    // If no item was selected, index is -1. We cannot edit
    // a contact if no contact item in the names component was
    // selected - because we would have nothing to work with.
    if (index != -1)
    // Remove the contact item from the names component.
    names.remove (index);
    // Remove the Contact object from the contacts Vector
    // object.
    contacts.remove (index);
    // If there are no more contacts ...
    if (contacts.size () == 0)
    delete.setEnabled (false);
    edit.setEnabled (false);
    else
    // Make sure that the first contact item in the names
    // list is highlighted.
    names.select (0);
    private void add ()
    // Create an add data entry form to enter information
    // for a new contact.
    DataEntryForm def = new DataEntryForm (this, "add");
    // If the bOk Boolean flag is set, this indicates the user
    // exited the form by pressing the Ok button.
    if (def.bOk)
    // Create a Contact object and assign information from
    // the form to its fields.
    Contact temp = new Contact ();
    temp.fname = new String (def.fname.getText ());
    temp.lname = new String (def.lname.getText ());
    temp.haddress = new String (def.haddress.getText ());
    temp.maddress = new String (def.maddress.getText ());
    temp.phone = new String (def.phone.getText ());
    temp.wphone = new String (def.wphone.getText ());
    temp.cphone = new String (def.cphone.getText ());
    temp.email = new String (def.email.getText ());
    temp.bdate = new String (def.bdate.getText ());
    temp.comments = new String (def.comments.getText ());
    // Add a new contact item to the names component.
    names.add (temp.lname + ", " + temp.fname);
    // Add the Contact object to the contacts Vector
    // object.
    contacts.add (temp);
    // Make sure that the delete and edit buttons are
    // enabled.
    delete.setEnabled (true);
    edit.setEnabled (true);
    // Destroy the dialog box.
    def.dispose ();
    // Make sure that the first contact item in the names list
    // is highlighted.
    names.select (0);
    // ===========================================================
    // Load all contacts from contacts.dat into the contacts
    // Vector object. Also, make sure that the last name/first
    // name from each contact is combined into a String object and
    // added into the names component - as a contact item.
    // ===========================================================
    private void loadContacts ()
    FileInputStream fis = null;
    try
    fis = new FileInputStream ("contacts.dat");
    DataInputStream dis = new DataInputStream (fis);
    int nContacts = dis.readInt ();
    for (int i = 0; i < nContacts; i++)
    Contact temp = new Contact ();
    temp.fname = dis.readUTF ();
    temp.lname = dis.readUTF ();
    temp.haddress = dis.readUTF ();
    temp.maddress = dis.readUTF ();
    temp.phone = dis.readUTF ();
    temp.wphone = dis.readUTF ();
    temp.cphone = dis.readUTF ();
    temp.email = dis.readUTF ();
    temp.bdate = dis.readUTF ();
    temp.comments = dis.readUTF ();
    names.add (temp.lname + ", " + temp.fname);
    contacts.add (temp);
    if (nContacts > 0)
    delete.setEnabled (true);
    edit.setEnabled (true);
    catch (Exception e)
    finally
    if (fis != null)
    try
    fis.close ();
    catch (Exception e) {}
    // Make sure that the first contact item in the names list
    // is highlighted.
    names.select (0);
    // ========================================================
    // Save all Contact objects from the contacts Vector object
    // to contacts.dat. The number of contacts are saved as an
    // int to make it easy for loadContacts () to do its job.
    // ========================================================
    private void saveContacts ()
    FileOutputStream fos = null;
    try
    fos = new FileOutputStream ("contacts.dat");
    DataOutputStream dos = new DataOutputStream (fos);
    dos.writeInt (contacts.size ());
    for (int i = 0; i < contacts.size (); i++)
    Contact temp = (Contact) contacts.elementAt (i);
    dos.writeUTF (temp.fname);
    dos.writeUTF (temp.lname);
    dos.writeUTF (temp.haddress);
    dos.writeUTF (temp.maddress);
    dos.writeUTF (temp.phone);
    dos.writeUTF (temp.wphone);
    dos.writeUTF (temp.cphone);
    dos.writeUTF (temp.email);
    dos.writeUTF (temp.bdate);
    dos.writeUTF (temp.comments);
    catch (Exception e)
    MsgBox mb = new MsgBox (this, "CM Error",
    e.toString ());
    mb.dispose ();
    finally
    if (fos != null)
    try
    fos.close ();
    catch (Exception e) {}
    private void edit ()
    // Obtain index of selected contact item from the names
    // component.
    int index = names.getSelectedIndex ();
    // If no item was selected, index is -1. We cannot edit
    // a contact if no contact item in the names component was
    // selected - because we would have nothing to work with.
    if (index != -1)
    // Obtain a reference to the Contact object (from the
    // contacts Vector object) that is associated with the
    // index.
    Contact temp = (Contact) contacts.elementAt (index);
    // Create and display an edit entry form.
    DataEntryForm def = new DataEntryForm (this, "edit",
    temp.fname,
    temp.lname,
    temp.haddress,
    temp.maddress,
    temp.phone,
    temp.wphone,
    temp.cphone,
    temp.email,
    temp.bdate,
    temp.comments);
    // If the user pressed Ok...
    if (def.bOk)
    // edit the contact information in the contacts
    // Vector object.
    temp.fname = new String (def.fname.getText ());
    temp.lname = new String (def.lname.getText ());
    temp.haddress = new String (def.haddress.getText ());
    temp.maddress = new String (def.maddress.getText ());
    temp.phone = new String (def.phone.getText ());
    temp.wphone = new String (def.wphone.getText ());
    temp.cphone = new String (def.cphone.getText ());
    temp.email = new String (def.email.getText ());
    temp.bdate = new String (def.bdate.getText ());
    temp.comments = new String (def.comments.getText ());
    // Make sure the screen reflects the edit.
    names.replaceItem (temp.lname + ", " + temp.fname,
    index);
    // Destroy the dialog box.
    def.dispose ();
    // Make sure that the first contact item in the names
    // list is highlighted.
    names.select (0);
    // ========================================================
    // Class: Contact
    // This class describes the contents of a business contact.
    // ========================================================
    class Contact
    public String fname;
    public String lname;
    public String haddress;
    public String maddress;
    public String phone;
    public String wphone;
    public String cphone;
    public String email;
    public String bdate;
    public String comments;
    // ==========================================================
    // Class: DataEntryForm
    // This class provides a data entry form for entering contact
    // information.
    // ==========================================================
    class DataEntryForm extends Dialog implements ActionListener
    // bOk is a boolean flag. When true, it indicates that
    // the Ok button was pressed to terminate the dialog box
    // (as opposed to the Cancel button).
    public boolean bOk;
    // The following components hold the text that the user
    // entered into the visible text fields.
    public TextField fname;
    public TextField lname;
    public TextField haddress;
    public TextField maddress;
    public TextField phone;
    public TextField wphone;
    public TextField cphone;
    public TextField email;
    public TextField bdate;
    public TextField comments;
    public void actionPerformed (ActionEvent e)
    // If the user pressed the Ok button, indicate this
    // by assigning true to bOk.
    if (e.getActionCommand ().equals ("Ok"))
    bOk = true;
    // Destroy the dialog box and return to the point
    // just after the creation of the DataEntryForm object.
    dispose ();
    public DataEntryForm (Frame parent, String title)
    // Call the other constructor. The current constructor
    // is used for add operations. The other constructor
    // is used for edit operations.
    this (parent, title, "", "", "", "", "", "", "", "", "", "");
    public DataEntryForm (Frame parent, String title,
    String fname, String lname,
    String haddress, String maddress,
    String phone,String wphone,
    String cphone,String email,
    String bdate,String comments)
    // Initialize the superclass layer.
    super (parent, title, true);
    // Choose a grid bag layout so that components can be more
    // accurately positioned. (It looks nicer.)
    setLayout (new GridBagLayout ());
    // Add appropriate first name, last name, phone, wphone, and
    // email components to the current DataEntryForm container.
    // (Remember, DataEntryForm is a subclass of Dialog.
    // Dialog is a container. Therefore, DataEntryForm
    // inherits the ability to be a container.)
    addComponent (this, new Label ("First Name: "),0, 0, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.fname = new TextField (20);
    addComponent (this, this.fname, 1, 0, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    if (title.equals ("edit"))
    this.fname.setText (fname);
    addComponent (this, new Label ("Last Name: "), 0, 1, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.lname = new TextField (20);
    addComponent (this, this.lname, 1, 1, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    if (title.equals ("edit"))
    this.lname.setText (lname);
    addComponent (this, new Label ("Home Address: "), 0, 2, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.haddress = new TextField (20);
    addComponent (this, this.haddress, 1, 2, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    if (title.equals ("edit"))
    this.haddress.setText (haddress);
    addComponent (this, new Label ("Mailing Address: "), 0, 3, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.maddress = new TextField (20);
    addComponent (this, this.maddress, 1, 3, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    if (title.equals ("edit"))
    this.maddress.setText (maddress);
    addComponent (this, new Label ("Home Number: "), 0, 4, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.phone = new TextField (20);
    addComponent (this, this.phone, 1, 4, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    if (title.equals ("edit"))
    this.phone.setText (phone);
    addComponent (this, new Label ("Work Number: "), 0, 5, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.wphone = new TextField (20);
    addComponent (this, this.wphone, 1, 5, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    if (title.equals ("edit"))
    this.wphone.setText (wphone);
    addComponent (this, new Label ("Cell Number: "), 0, 6, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.cphone = new TextField (20);
    addComponent (this, this.cphone, 1, 6, 1, 1,
    GridBagConstraints.WEST,
    GridBagConstraints.WEST);
    addComponent (this, new Label ("Email Address: "), 0, 7, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.email = new TextField (20);
    addComponent (this, this.email, 1, 7, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    addComponent (this, new Label ("Birth Date: "), 0, 8, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.bdate = new TextField (20);
    addComponent (this, this.bdate, 1, 8, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    addComponent (this, new Label ("Comments: "), 2, 0, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    this.comments = new TextField (20);
    addComponent (this, this.comments, 2, 1, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    addComponent (this, new Label (""), 0, 9, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    addComponent (this, new Label (""), 1, 9, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.WEST);
    Button b;
    // Add an Ok button to this container.
    addComponent (this, b = new Button ("Ok"), 0, -9, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    b.addActionListener (this);
    // Add a Cancel button to this container.
    addComponent (this, b = new Button ("Cancel"), 1, -9, 1, 1,
    GridBagConstraints.NONE,
    GridBagConstraints.CENTER);
    b.addActionListener (this);
    // Set the background of the frame window container to
    // pink (to give a pleasing effect).
    setBackground (Color.pink);
    // Set the size of the dialog window to 250 pixels
    // horizontally by 200 pixels vertically.
    setSize (450, 500);
    // Do not allow users to resize the dialog window.
    setResizable (false);
    // Make sure that the dialog window is visible.
    setVisible (true);
    private void addComponent (Container con, Component com,
    int gridx, int gridy,
    int gridw, int gridh, int fill,
    int anchor)
    // Get the current layout manager. It is assumed to
    // be a GridBagLayout object.
    LayoutManager lm = con.getLayout ();
    // Create a GridBagConstraints object to make it
    // possible to customize component positioning.
    GridBagConstraints gbc = new GridBagConstraints ();
    // Assign the x and y grid positions.
    gbc.gridx = gridx;
    gbc.gridy = gridy;
    // Assign the number of grid blocks horizontally and
    // vertically that are occupied by the component.
    gbc.gridwidth = gridw;
    gbc.gridheight = gridh;
    // Specify the component's resize policy (fill) and
    // the direction in which the component is positioned
    // when its size is smaller than available space (anchor).
    gbc.fill = fill;
    gbc.anchor = anchor;
    // Set the new constraints that the grid bag layout
    // manager will use.
    ((GridBagLayout) lm).setConstraints (com, gbc);
    // Add the component to the container.
    con.add (com);
    // ===========================================================
    // Class: MsgBox
    // This class displays a message box to the user. The message
    // is usually an error message. The user must press the Ok
    // button to terminate the message box.
    // ===========================================================
    class MsgBox extends Dialog implements ActionListener
    public void actionPerformed (ActionEvent e)
    // Terminate the dialog box in response to the user
    // pressing the Ok button.
    dispose ();
    public MsgBox (Frame parent, String title, String msg)
    // Initialize the superclass layer.
    super (parent, title, true);
    // Store the msg argument in a Label object and add
    // this object to the center part of the dialog window.
    Label l = new Label (msg);
    add ("Center", l);
    // Create a Button object and add it to the south part
    // of the dialog window.
    Button b = new Button ("Ok");
    add ("South", b);
    // Make the current object a listener to events that
    // occur as a result of the user pressing the Ok
    // button.
    b.addActionListener (this);
    // Make sure that the Ok button has the focus.
    b.requestFocus ();
    // Do not allow users to resize the dialog window.
    setResizable (false);
    // Allow the layout manager to choose an appropriate
    // size for the dialog window.
    pack ();
    // Make sure that the dialog window is visible.
    setVisible (true);
    ====================END OF CODE =======================

    You should first start by formatting the code before
    posting. I lost my interest as I browsed thorugh the
    code.
    Read here -
    http://forum.java.sun.com/help.jspa?sec=formatting
    ...and its way too much code to expect anyone to read. Post a short excerpt of the part you are having trouble with.

  • Error after compile Exception in thread "main" java.lang.NoClassDefFoundErr

    Hi I am very new to Java programming, right now I am using a mac os 10.49
    I can create java documents using bbedit and then they compile when i type
    javac.
    But when i type java *.java I get the following error
    Exception in thread "main" java.lang.NoClassDefFoundError
    If I type java "filename"
    without the .java at the end of the file the terminal has no response
    I understand i am supposed to some how set the classpath but i do not know how to do this
    Also I can create and compile and then run my java in the eclipse program that i have installed, but not from terminal and im not sure why.
    Thanks for the help.

    I understand i am supposed to some how set the classpath but i do not know how
    to do thisThere is no need to set a system variable CLASSPATH, it is inflexible to do so, and it can lead to unpredictable behaviour.
    You should be able to compile and run programs from the command line, specifying the classpath as part of the commands you use.
    (1) For instance, you can create a file HelloWorld.java with the following contents:public class HelloWorld {
        public static void main(String args[]) {
            System.out.println("Hello world");
    }(2) From the command line (console) navigate to the folder (directory) containing this file and compile it with the commandjavac -cp . HelloWorld.javaThe "-cp ." part is what specifies the classpath. Note that it is a file that is being compiled so we specify the actual file name including the extension. At this point you should be able to check that the HelloWorld.class file has been created.
    (3) From the same folder (directory) you run the program withjava -cp . HelloWorldThe classpath is being specified in the same way as before. It is a class that is being invoked, so we don't specify a filename. (much less use wildcards like *).
    Documentation for the java and javac tools (and others) are linked to from this page: http://java.sun.com/javase/6/docs/index.html

Maybe you are looking for

  • Adobe Photoshop CS5  has stopped working (weird)

    Hallo Friends, This i my first post here, hope to help me to get rid this problem of. well i'm using Photoshop CS5 (Extended) With Sum Plugins Alien SKin Bokeh Nik Color Efex Pro Dfine Imagenomic Portraiture when i had CS4, no problems were happening

  • Can we create new cref.exe

    Hi all, suppose if we modify the source code present in java card framework and then compile them to class files, converting these class files to JCA files , generating mask files from these JCA files, and using these mask files along with C code ava

  • How do I disable all HTML in incoming email messages?

    I just switched from Thunderbird to Mail and discovered that I cannot disable HTML rendering in email. I don't want to turn off only images. I want all HTML commands to be ignored. Most HTML is an annoyance, esp. with all the bad web designers who pu

  • How to create Support Project

    Hi, We using SOLMAN 7.0 and are in Support Phase now, so need to create support project in SOLMAN. Please advice me for creating SUPPORT Project in system

  • Ipad shows email but I do not have any how do I get rid of it

    How do I get rid of the email notification when I do not have any