DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2004

    completly new to Java , using a Mac and don't know how to make executables!

    Hi! , Im trying to use Mac OS X panther's terminal to compile , but i don't know how to make an executable, all i know is that there is .jar , .java and .class.

    Ive always programmed in c++, so i understand the code i see in .java files and supposedly you should be able to compile like this " java javafile.java" , "jar javafile.jar" but this dosen't work and a messege appears :

    Exception in thread "main" java.lang.NoClassDefFoundError

    and the problem is that the file does have a main function.

    any info would be much appreciated and plz no Xcode suggestions

  2. #2
    Join Date
    Sep 2004
    is thereno one that can help me?

  3. #3
    Join Date
    Sep 2004
    Fist you complie using

    >javac JavaFile.java make sure file name and class name should be same and casesensetive also
    eg: class name is JavaFile you must same this file as JavaFile.java
    then complie.
    it will work and run using .>java JavaFile.java
    it will show u output.


  4. #4
    Join Date
    Jun 2004
    let us know if you are having issues still. I didn't check this forum for a few days. Took a rest from telling people that java != javascript.

  5. #5
    Join Date
    Sep 2004
    thx to samifarooq and mntall to care and answer, ive been reading a lot , java is realy similar to c++ , i have 2 Questions that would help alot if they are answered :

    1- How do you input ?? i know that output(one way of) is System.out.println("" or x) but i can't find anywhere in my tutorial and in other ones ive check how to input.

    2- can some one show me a decent try format (throwing normal variables(not weird ones) ) and the name that the catch parameter has to have. i can't find a decent example anywhere .

    thanks for answering and hope you can helpme!

    sincerly zyracks.

  6. #6
    Join Date
    Jun 2004
    Yes, Java is very similar to C++, if you do OOP and not C in C++ .

    Just remember - there are no exe's in Java (unless you get a third party tool to do it), no dual inheritance and no useful destructors.

    To answer your questions:

    1. System.in

    2. You need to know what the method you are calling will throw. The method signature will tell you if there is a checked exception being thrown. Your best bet is to use a good IDE. Check out Eclipse or Netbeans for $0 ones.

  7. #7
    Join Date
    Sep 2004
    a i still have some douts anout thos 2 questions.

    1 is it just System.in ? cuse the output is System.out.PRINTLN() i do not no if i need something like the println after .in

    2 if i want tu return an integer value how can i do it and what type of name should the catch parameter have (integer, int, int f, integer f, f,) i really do not know!!!!

  8. #8
    Join Date
    Jun 2004
    1. System.in is the InputStream class.


    2. See the above link.

  9. #9
    Join Date
    Nov 2004
    1. There are quite a few ways to read input. Some possiblilities:

    //Read directly from System.in, like so:
    byte buf[] = new byte[n];
    System.in.read(buf); // and variants

    //Wrap System.in in a BufferedReader:

    BufferedReader br = new BufferedReader(System.in);

    String line = br.readln();

    //Or wrap it in some other type of Reader (see the Reader javadoc, and look for derived classes)

    2. Here's a try/catch example:

    System.out.println("Before the try block");
    System.out.println("Entered try block");
    throw new Exception("Program Error");
    } catch(Exception e) {
    System.out.println("Caught an exception: " + e.getMessage());
    } finally {
    System.out.println("This block is always run, whether there was an exception or not. Do cleanup here!");
    System.out.println("After the try block");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.