[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: compilando programas com java no debian



Aqui está o programa java

package org.opensourcephysics.stp.ising2d;
import org.opensourcephysics.display.*;
import org.opensourcephysics.display2d.*;
import java.awt.*;

public class Ising2D implements Drawable {
   public static final double criticalTemperature = 2.0/Math.log(1.0 +
Math.sqrt(2.0));

   public int [][] spin;
   public int L;
   public int N;                 // Number of sites
   public double T;              // Temperature
   public double H;              // External magnetic field
   public double E;              // System energy
   public double E_acc;          // E accumulator
   public double E2_acc;         // E^2 accumulator
   public int M;                 // System magnetization
   public double M_acc;          // M accumulator
   public double M2_acc;         // M^2 accumulator

   public int mcs;               // Number of MC moves per spin
   public int acceptedMoves;     // Used to determine acceptance ratio

   private CellLattice lattice;  // Used only for drawing


   public void initialize(int _L, double _T, double _H) {
      L=_L;
      N = L*L;
      T = _T;
      H = _H;

      lattice = new CellLattice(L,L);         // only used for drawing
      lattice.setIndexedColor(0, Color.red);
      lattice.setIndexedColor(2, Color.green);

      // all spins up
      spin = new int[L][L];
      for (int i = 0; i < L; ++i)
         for (int j = 0; j < L; ++j)
            spin[i][j] = 1;

      M = N;
      E = -2*N - H*M;
      resetData();
   }

   public void setTemperature(double _T) {
      T = _T;
   }

   public void setExternalField(double _H) {
      E += H*M - _H*M;
      H = _H;
   }

   public double specificHeat() {
      double E2_avg = E2_acc / mcs;
      double E_avg = E_acc / mcs;
      return (E2_avg - E_avg*E_avg) / (T*T*N);
   }

   public double susceptibility() {
      double M2_avg = M2_acc/mcs;
      double M_avg = M_acc / mcs;
      return (M2_avg - M_avg*M_avg) / (T*N);
   }

   public void resetData() {
      mcs = 0;
      E_acc = 0;
      E2_acc = 0;
      M_acc = 0;
      M2_acc = 0;
      acceptedMoves = 0;
   }

   public void doOneMCStep() {
      for (int k = 0; k < N; ++k) {
         int i = (int)(Math.random()*L);
         int j = (int)(Math.random()*L);
         double dE = 2*spin[i][j]*(H + spin[(i+1)%L][j] +
spin[(i-1+L)%L][j] + spin[i][(j+1)%L] + spin[i][(j-1+L)%L]);
         if (dE <= 0 || Math.random() < Math.exp(-dE/T)) {
            spin[i][j] = -spin[i][j];
            acceptedMoves++;
            E += dE;
            M += 2*spin[i][j];
         }
      }
      E_acc += E;
      E2_acc += E*E;
      M_acc += M;
      M2_acc += M*M;
      mcs++;
   }

   public void draw (DrawingPanel panel, Graphics g) {
      if(lattice==null) return;
      for(int i = 0; i < L; i++)
         for(int j = 0; j < L; j++)
            lattice.setValue(i,j,(byte)(spin[i][j]+1));
      lattice.draw(panel,g);
   }
}


Francisco Welington de Sousa Lima
> Olá pessoal,
>
>     Baixei o java da SUN e fiz tudo como estava lá para instalar em meu
> debian sarge, e tenho um pacote de programas escrito em java e quero
> compilá-los , mas todos dão erro. Sou ingnorante em java não sei se ele
> roda no linux abrindo a janela e mostrando a simulação em tempo real ou
> se se precisa de uma página na internet para funciona por isso preciso
> da ajuda de vocês porque tenhos muitos programas educativos e gostaria
> de vê-los funcionando.
> Vejam  o meu diretório.
>
> wel@Julia:~/kip/physics/org/opensourcephysics/stp/ising2d$ ls
>
> AutoCorrelator.java  Ising2DApp.java     Ising2D.java
> history.html         Ising2DApplet.java
>
> wel@Julia:~/kip/physics/org/opensourcephysics/stp/ising2d$
> agora vou compilar com javac o Ising2D.java
>
> wel@Julia:~/kip/physics/org/opensourcephysics/stp/ising2d$ javac
> Ising2D.java
>
> Found 6 semantic errors compiling "Ising2D.java":
>
>      2. import org.opensourcephysics.display.*;
>                ^---------------------------^
> *** Semantic Error: You need to modify your classpath, sourcepath,
> bootclasspath, and/or extdirs setup. Jikes could not find package
> "org.opensourcephysics.display" in:
>                 /usr/lib/kaffe/pthreads/jre/lib/rt.jar
>                 .
>
>
>
>      3. import org.opensourcephysics.display2d.*;
>                ^-----------------------------^
> *** Semantic Error: You need to modify your classpath, sourcepath,
> bootclasspath, and/or extdirs setup. Jikes could not find package
> "org.opensourcephysics.display2d" in:
>                 /usr/lib/kaffe/pthreads/jre/lib/rt.jar
>                 .
>
>
>
>      6. public class Ising2D implements Drawable {
>                                         ^------^
> *** Semantic Error: Type "org.opensourcephysics.stp.ising2d.Drawable"
> was not found.
>
>
>     24.    private CellLattice lattice;  // Used only for drawing
>                    ^---------^
> *** Semantic Error: Type "org.opensourcephysics.stp.ising2d.CellLattice"
> was not found.
>
>
>     33.       lattice = new CellLattice(L,L);         // only used for
> drawing
>                             ^---------^
> *** Semantic Error: Type "CellLattice" was not found.
>
>
>     97.    public void draw (DrawingPanel panel, Graphics g) {
>                              ^----------^
> *** Semantic Error: Type
> "org.opensourcephysics.stp.ising2d.DrawingPanel" was not found.
> wel@Julia:~/kip/physics/org/opensourcephysics/stp/ising2d$
> Não sei o que está acontecendo alguém pode me ajudar?
>
> F. W. S. Lima
> Departamento de Física
> Centro de Ciência da Natureza
> Campus Petrônio Portela
> Universidade Federal do Piauí
> Teresina-Piauí-Brasil
> wel@ufpi.br,wel@fisica.ufc.br, wel@sobral.org
>
>
>
> --
> To UNSUBSCRIBE, email to debian-user-portuguese-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
> listmaster@lists.debian.org


F. W. S. Lima
Departamento de Física
Centro de Ciência da Natureza
Campus Petrônio Portela
Universidade Federal do Piauí
Teresina-Piauí-Brasil
wel@ufpi.br,wel@fisica.ufc.br, wel@sobral.org




Reply to: