Using eclipse to compile and execute Java apps??

Discussion in 'Mac Programming' started by obelix, Oct 20, 2004.

  1. macrumors member

    Joined:
    Oct 20, 2004
    #1
    I just downloaded eclipse and all I want to do is compile and run a command line java application. For the life of me I can't figure out how this is done. In netbeans it's all setup for you but in eclipse it doesn't seem to do anything when I hit the build button. It highlights code that is incorrect but will not provide any feedback on what the problems are. Worse yet I can't get it to execute anything. Can anyone help???
     
  2. macrumors 68040

    cluthz

    Joined:
    Jun 15, 2004
    Location:
    Norway
    #2
    you won't need eclipse or anything else to run and compile java apps.

    Use the terminal to do it:

    javac filename.java
    (to compile)

    java filename.java
    (to execute/run)
     
  3. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #3
    (In lieu of getting an eclipse book or browsing the help files....)

    From the beginning (or as close as I can get - I've been using eclipse and forget what I've changed from the default settings):

    * Start up eclipse and create a new workspace directory.

    * File->New...->Project

    - create a Java project, name it, and put it where you want.

    * File->New...->Class

    - create the Java file(s) you want to use and make sure at least one has a main() method.
    - saving changes should show any errors in the "Problems" tab at the bottom

    * Run->Run...

    - Choose "Java application"
    - search for the main class if you need to; it might be already set for you
    - assuming your program outputs anything, a console tab should show up in your view with the output

    I've attached a simple example's view.

    Best of luck!
     

    Attached Files:

  4. macrumors newbie

    Joined:
    Nov 20, 2006
    #4
    eclipse anime

    im trying to do some animation on eclipse(mac) , and it's not working...
    below there's a simple animation i can run on windows.... help

    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    class chute extends JFrame implements MouseMotionListener{
    public JLabel x,y;
    public JPanel p1;
    public static void main(String[]args){
    JFrame janela=new chute();
    janela.show();
    }
    chute(){
    setTitle("chute");
    getContentPane().setLayout(new BorderLayout());
    setSize(300,300);
    setLocation(90,90);
    p1=new JPanel();
    p1.setLayout(new BorderLayout());
    x=new JLabel("x");
    y=new JLabel("y");
    p1.add(x,"North");
    p1.add(y,"South");
    getContentPane().addMouseMotionListener(this);
    getContentPane().add(p1,"South");

    }
    public void paint(Graphics g){
    int d=0;
    do{
    Graphics2D g2d = ( Graphics2D ) g;
    double i=0;
    do{
    super.paint(g);
    double x1=230-i;
    double x2=200;
    g2d.draw(new Line2D.Double(190,140,225,80));
    g2d.draw(new Line2D.Double(190,140,x1,200));
    g2d.fill(new Rectangle2D.Double(x1-30,x2-9,30,10));
    g.fillOval(100,160,40,40);
    i+=0.3;
    }while(i<62);
    i=0;
    double j=0;
    do{
    super.paint(g);
    double x1=198+i;
    double x2=200;
    g2d.draw(new Line2D.Double(190,140,225,80));
    g2d.draw(new Line2D.Double(190,140,x1,200));
    g2d.fill(new Rectangle2D.Double(x1-30,x2-9,30,10));
    g2d.fill(new Ellipse2D.Double(100-j,160-i,40,40));
    j+=0.5;
    i+=0.1;
    }while(i<30);
    d++;
    }while(d<2);
    }
    public void mouseMoved(MouseEvent e){
    x.setText("X: "+e.getX());
    y.setText("Y: "+e.getY());
    }
    public void mouseClicked(MouseEvent e){}
    public void mouseDragged(MouseEvent e){}
    public void mouseEntered(MouseEvent e){}
    public void mouseExited(MouseEvent e){}
    public void mousePressed(MouseEvent e){}
    public void mouseReleased(MouseEvent e){}
    //calculo de rotaÁ„o
    /*public static double calculo1(double x,double y,double b){
    double tot=((Math.cos(b*3.14/180)*x)-(Math.sin(b*3.14/180)*y));
    return tot;
    }
    public static double calculo2(double x,double y,double b){
    double tot=0;
    tot=((Math.cos(b*3.14)*y)+(Math.sin(b*3.14/180)*x));
    return tot;
    }*/

    }


     
  5. macrumors 603

    jeremy.king

    Joined:
    Jul 23, 2002
    Location:
    Fuquay Varina, NC
    #5
    Actually, all the problems can be seen in the Problems view, depending on the Perspective you are using may or may not be shown. If you don't see it, Window > Show View > Problems
    Of course you can't run it until you fix compile issues.


    Since you have no idea what you are doing, I would HIGHLY suggest that you run through the tutorials/overviews under Help > Welcome.

    Edit: Didn't realize this thread is a month old...good information for others though.
     

Share This Page