My first program in Java

After I compile my first application using javac Welcome1.java
when I try to run the pplication using java Welcome1
I get this message
Exception in thread "main" java.lang.NoClassDefFoundError: Welcome1
Please if somebody can help me:
This is my source code:
// Fig. 2.1 Welcome1.java
// A first program in Java.
     public class Welcome1 {
     // main method begins execution of Java application
     public static void main ( String args[] )
          System.out.println( "Welcome to Java Programming!" );
     } // end method main
}     // end class Welcome1
Thank you

Try this
go to c:\edit autoexec.bat
type these lines
set path=c:\j2sdk1.4.0\bin; // check the java folder name in c:\
set classpath=c:\%classpath%;.;
save and close DOS
restart PC,
now try the example
Hope it helps
Uma
http://www.javagalaxy.com

Similar Messages

  • I created my first program-compiling error-help please

    hey there
    i just wanted my first program in java and here it is below with the eroor when i'm compiling it, i cant understand whats wrong:
    public class SquareArea {
         public static void main(String[] args); {
         float length;
         float width;
         float SquareArea;
         System.out.println ("Please enter length"+ length);
         System.out.println ("Please enter width"+ width);
         SquareArea= length*width;
         System.out.println ("The area of the square is" + SquareArea);
    The error is:C:\Documents and Settings\User\Desktop\SquareArea.java:5: missing method body, or declare abstract
         public static void main(String[] args); {
    ^
    1 error
    Tool completed with exit code 1

    There shouldn't be a semicolon between the ")" and the "{" near the end of that line.
    With that semicolon, you're basically defining an empty, zero-size main method, and then throwing a bunch of garbage after it. That's what the compiler thinks anyway. Remove that semicolon and it should compile OK.
    But it won't work super well, because you're not actually getting any input for length and width. It's just going to output this:
    Please enter length0
    Please enter width0
    The area of the square is0

  • How to call a program in another program in java

    first program: test1.java
    seccond :main.java
    run main.java in which i call test1.java
    Edited by: user13488971 on Dec 15, 2010 6:15 PM
    Edited by: user13488971 on Dec 15, 2010 6:15 PM

    user13488971 wrote:
    first program: test1.java
    seccond :main.java
    run main.java in which i call test1.java
    Edited by: user13488971 on Dec 15, 2010 6:15 PM
    Edited by: user13488971 on Dec 15, 2010 6:15 PMYou sound like you're coming from a procedural programming backround, as did I ... as did a lot of us. Sounds like you are thinking of these two as a main and a sub program. If not, I apologize, and promptly bow out. But if so, don't think like that in Java (or any OOPs based language). What you want to do is think "class", not program. A Java "file" is only loosely a program, in the more traditional sense. It can contain more than one class - though only one top level public class. Classes both within and outside each java "file" (test1.java, for instance) can create instances of other classes and call their methods - as others just explained. There are many caveats to this, but that's the gist of it.

  • My first program to create a crystal report from java... Help needed...

    Hi... I am writing a java program that fetches a table from database and creates a Crystal Report from that table(ResultSet object)... Optionally exporting the report as a pdf also...  This will be a console application since it is my first program using crystal reports.... Any one can help me with this...?

    Hi Karthik,
    you could have a look over these developer guides below for understanding of Java sdk :-
    [http://www.sdn.sap.com/irj/boc/sdklibrary|http://www.sdn.sap.com/irj/boc/sdklibrary]
    you could also find  below sample codes for creating reports using Java sdk (RAS sdk) :-
    [http://www.sdn.sap.com/irj/boc/samples|http://www.sdn.sap.com/irj/boc/samples]
    let me know if you need any help,
    Regards,
    Rameez.

  • Asynchronous socket programming in Java?

    I am a C++ programmer, I just wonder how do I do asynchronous programming in Java?
    In VC++, you can hook an event handler to the socket and the system will fire an event whenever there is data coming in to the socket. The event handler can then spawn a thread and handle the network message.
    In Unix, you can use the select() function. This function will return whenever the indicated socket fires events. If nothing happens within the timeout period, the function simply returns.
    What about in Java? I don't see any methods that allows you to hook an event handler to it. Is there anything like select() function in Unix?
    Thanks so much.

    There is something very much like C's select: selectors. I don't immediately know where to read more about them but google for things like "java selector example", "java nio tutorial", etc (NIO = new I/O, the library where selectors live.)
    Another way to do async sockets in Java is by threading. That is the traditional way before New I/O. It's still a perfectly good and easy way, thanks to Java's easy threading. Downside is that it scales to only maybe 100-200 simultaneous connections per server (will depend on your operating system). For thread-based sockets check Sun's Java socket tutorial (first item when you google "java socket tutorial").

  • Problem compiling my first program; Please Help me!

    Please HELP, what am I doing wrong?
    For over 5hours I have been trying to figure out how to compile a simple Hello world program using sdk1.3.1_02/j2re1.3.1_02 and I am getting the following errors: helloworld.java:2 cannot resolve symbol
    symbol : class string
    location : class helloworld
    cannot reolve the string symbol
    symbol : class out
    location : package system
    I want to program in java so badly but I am trying to get my environment set so that I can take off. To compile my first program has been a disaster!!
    This is my path:
    SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\JDK1.3.1_02\BIN
    Thanks very much in advance
    ::(

    Java is case sensitive,
    use String instead of string. and System.out instead of system.out
    Sudha

  • Never programmed with Java

    Hello
    I have never programmed with Java, and dont know, what i can do, I use PHP, but, i am only a novice at it.
    I was wondering, is it possable to get data from a page, and put it into an image? if there is no data from the page, it will ask for the data to be added, and this will update every so often?
    Also, Most of you know about google maps, where you can search for something, well, can i do this same thing in java, have a map, not of the earth, but for a game, and make it easy to add different parts, so that we can search for it, and people can find it easy to look for what they are looking for?

    I think Google Maps is programmed in JavaScript using AJAX (short for Asynchronous JavaScript and XML) and is what as known as a web application. Google has released an API (still in beta) for working with Google Maps. The webpage for this API is http://www.google.com/apis/maps/. More about the development facilities Google provides can be found at http://code.google.com/.
    I've never read the source code to Google Maps before (a lot of which is available by just viewing the source code of the Google Maps webpage, which can be done by clicking, View > Source in Internet Explorer and View > Page Source in Mozilla Firefox), however I don't think it is a terribly complex application (this does not mean, however, that the source code is easy to read). I think the way it works is by requesting individual images as needed from the Google server and piecing them together on the client side (i.e. in the browser). Basically what you would need to do to use their existing code is to replace all requests made to the Google server with requests to a server of your own and have the server return the corresponding images. This might not be particularly easy to do.
    In my opinion, a better approach is just to write your own custom application (probably in Java) which simply mimics the behavior of Google maps, except with your own custom images. This way, you don't have to reverse engineer an entire web application before beginning to write one.
    Writing your own application for this purpose is not as difficult as it sounds, especially not in Java. Once understanding the basics, you will not be too far off from being able to write your application.
    Let's start with the most basic program (this program would be located in a file called Program.java):
    public class Program {
       public static void main(String[] args) {
    }This program simply starts, does nothing, and exits. I will explain this piece of code line by line, but first, I would like to gauge how much you already know to figure out how best to explain this. Have you used classes in PHP before?

  • Is it possible to create java standalone programs with java ME 8

    Hi,
    Comparing java ME to java SE, I have the impression that midlets are similar to applets.
    When working with java SE, I usually make standalone programs.
    Now, I wonder if it is also possible to create also standalone programs for java ME, if the classes are only  using java ME API's.
    I already noticed that netbeans does not allow to build a project that does not contain a midlet, but maybe, it is possible to create a jar file
    using the javac and jar commands. Or is there a specific reason why netbeans does not allow to build a project without midlets?
    The reason for asking is, that I often make small tools in java that ae then called from a linux script. I imagine that this might be useful on the raspberry pi as well.
    Thanks in advance
    Jef

    Hi Jef -
    Comparing java ME to java SE, I have the impression that midlets are similar to applets.
    Sort of - similar life cycle methods - so conceptually, yes.
    Now, I wonder if it is also possible to create also standalone programs for java ME, if the classes are only  using java ME API's.
    In a way, yes. If you build an project, you will notice a JAD file and JAR file in the dist directory of the project.  JAD is the descriptor for a MIDlet - in mobile devices, the JAD
    file is loaded first to determine if the MIDlet has enough privileges to load and run, before the corresponding JAR file is downloaded.
    However, the JAD file can also be included in the Manifest of the JAR and the JAR copied to the embedded device manually and run there.
    I already noticed that netbeans does not allow to build a project that does not contain a midlet, but maybe, it is possible to create a jar file
    using the javac and jar commands. Or is there a specific reason why netbeans does not allow to build a project without midlets?
    You can build JAR files and include them into Java ME Embedded projects, but just like Applets, to use the Application Management System (AMS) on the Raspberry Pi, you must have a MIDlet to run.
    Perhaps you mean that you would like to launch the AMS and load a MIDlet from the command line on the Pi?
    If so, take a look at this section of the Getting Started Guide for the Raspberry Pi.
    Tom

  • How to program in java

    hey guys. i am an undergraduate student. graduating next spring 2007. i did all my programming languages which were required in my course in 2004 and since that i have not taken any programming classes. i got my internship as a database administrator so got into MSaccess and Sql and VbA scripting. since my graduation year is near i want to be strong in database and programming and i was just reading about the employers what kind of programming they prefer and most of the times out of 100 you can say 80% needs java. so i have realized if i have my skills good in java and database job wont be any problem. i would like you to tell me about books i can buy from amazon.com or resources on internet from which i can understand the concept of programming again and then once my concept is clear about all the data types and functions i can start learning java. i would like you to tell me good java books also and some advance. the only book i have is the second edition of Java how to program. Thanks alot for all your help.

    The perverbial List:
    Free Tutorials and Such
    Installation Notes - JDK 5.0 Microsoft Windows (32-bit)
    Your First Cup of Java
    The Java� Tutorial - A practical guide for programmers
    New to Java Center
    Java Programming Notes - Fred Swartz
    How To Think Like A Computer Scientist
    Introduction to Computer science using Java
    The Java Developers Almanac 1.4
    Object-Oriented Programming Concepts
    Object-oriented language basics
    Don't Fear the OOP
    Free Java Books
    Thinking in Java, by Bruce Eckel (Free online)
    Core Servlet Programming, by Merty Hall (Free Online)
    More Servlets, by Marty Hall (Free Online)
    A Java GUI Programmer's Primer
    Data Structures and Algorithms
    with Object-Oriented Design Patterns in Java, by Bruno R. Preiss
    Introduction to Programming Using Java, by David J. Eck
    Advanced Programming for the Java 2 Platform
    The Java Language Specification
    Books:
    Head First Java, by Bert Bates and Kathy Sierra
    Core Java, by Cay Horstmann and Gary Cornell
    Effective Java, by Joshua Bloch
    Enjoy
    JJ

  • Can DDoS Attack program in java?

    Can we write powerful and disastrous exploit in Java such as DDOS attack,Sql injection,byte code attack,reversing
    other language's program?
    please end up my curiosity by your perfect solution. :)
    I will godly appreciate that, thanks in advance. :)
    best regards,
    JVegeta

    Dear Friends,
    can we develop program in java to identify the virus
    or unknown application is running in the system.
    I want to develop such kind of application in java.
    Which classes and methods are usefull for that in
    java.
    May I get some clue
    ThanksSome thoughts:
    You will need to define unknown before you can search for it.
    You might want to try a smaller project first, to learn the API. Then you will be able to determine what would be useful yourself.
    I would give you a clue but I am all out today.

  • OSX 10.4.10, Net beans and Sams Programing with JAVA

    I am brand new to Java so I downloaded Net Beans on my MAC. I bought a copy of Teach Your Self Programing with Java in 24 hrs.
    So far I got the first three programs to compile on Net Beans but got stuck when they started to talk about arguments. The following will not compile. Starting at line 2
    1) System.out.println("The " + arguments [0]
    2) + " " + arguments[1] + " fox "
    3) + "jumped over the "
    4) + arguments[2] + " dog. ")
    I get the little red x on each line.
    Is the book wrong or am I missing something?
    All the tutorials talk about Javac. I can't seem to find it or get to it on my computer. How do I know if I even have it?
    And is there such a thing as a "command line" on a MAC?

    Hi, you should put any code you post in between code brackets like this:
      code here   I dont use a mac or netbeans but javac is the java compiler, you would not have been able to compile the first two. The .exe (or whatever mac executable is) is usually located in the lib folder in the java directory. It comes when you download JDK. As for the code, it would help me if you posted the first couple lines of the error message. It looks fine to me, but I would need to see your whole class in order to help you further
    and yes there is a command line on a mac...i think its called terminal and usually looks like a little computer
    Edited by: jaredL on Sep 20, 2007 7:45 PM
    Edited by: jaredL on Sep 20, 2007 7:47 PM

  • Mail Program using Java as...

    HI!
    Is this possible in java...
    to make Mail Program using Java as frontend & use Outlook Express database as backend
    PLease Help...
    Bunty India

    Hi Gandalf,
    I picked up your code and ran it, couple of things, firstly windows and Unix line terminations are different so in your method doCommand use "\r\n" not just \n, this will give a full <CRLF>
    On you initial HELO you want to use your computer's id as part of the command so use this line:
    sender_domain = InetAddress.getLocalHost().getHostName();
    String s1 = new String("HELO " + sender_domain);
    s1.trim();
    response = doCommand(s1);
    Cheers
    Dom

  • Writing my first program....

    Okay my first programming assignment is to write a program that requests an amount of money and will then calculate how many quarters, dimes, nickels and pennies it takes to get that number. I do wanna figure this out by myself, but since im new to JAVA i was wondering if anyone could give me some ideas and/or hints as to maybe where a good place to start is.....

    A good way to start is for you to do what the program needs to do, and write down the steps involved.
    Assume you start with $1.01
    What would you do first?
    next?
    and so on.
    Each statement should consist on only one action.
    By the time you finish, you've pretty well outlined what the program needs to do.
    Then you can start figuring out wha program instructions are needed.

  • First Cup of Java problems

    Hi, i've been trying to learn Java2, I bought a book-Java2 a beginners guide, and that is how I found this site, they told me to download the JDK, I've ended up with j2sdk 1.4.0 it is located c:\j2sdk1.4.0 I've tried the first cup of java tutorial, and am having problems, when compiling-javac HelloWorldApp.java I get 'bad command or filename' so then I enter C:\j2sdk1.4.0\bin\javac HelloWorldApp.java and then I'm told that the program has performed an illegal operation and am kicked out. I tried to update the path variable, but don't seem to have any luck there either, some help or suggestions would be appreciated, I'm sure I can learn this stuff, at least I hope I can!!!!!
    :)Ang

    Does it say command not found?If it does, try changing directory to c:\j2sdk1.4.0\bin and agan typing javac and this time it should tell you the basic options for running javac.<<Doesn't say command not found, says 'Bad command or filename', then I tried c:\j2sdk1.4.0\bin and I get 'bad command or filename' again.......then I tried c:\j2sdk1.4.0\bin\javac and I get 'this program has performed an illegal operation' and am booted out...Is there some sort of setting that needs to be changed? I'm using windows 98. Thankyou for your help. Ang

  • How can I build Instalation Program for java applet?

    I want to build on line internet game based on java applet.
    Uset must instull the game to his computer.And this program mast Connect to the server when user enter
    to this application.Not from explorer,but from my application,like when i enter to ICQ.
    My questions:
    How can i build instalation program in java?
    How can i connect to the server when user enter into my game not from explorer but from game?
    Thanks,Maya.

    Hi Maya
    First of all an Applet does not have to be "installed" as you would with a normal application. The browser handles the install and execution of the applet.
    Check out this URL for more about applets:
    http://web2.java.sun.com/docs/books/tutorial/applet/index.html
    On the subject client/server pairs - see:
    http://web2.java.sun.com/docs/books/tutorial/networking/sockets/index.html
    If you decide to make the game an application instead check out Sun's WebStart - under the products section.
    That's about all the help I can give you.
    Programming a game is a complicated subject - I am doing one too:
    http://hjem.get2net.dk/mhjembaek/armageddon/
    Kind reg,
    Hjembaek

Maybe you are looking for