Calling a method from another servlet? very beginner

I am going to try to explain what I want to do so just be patient please.
I want to call a method in a seperate servlet to connect and release my connection pool - How do I do this?
This is what I have been trying... help
dbPOOL.class
package DATABASE;
import javax.naming.*;
import javax.sql.*;
import java.sql.*;
import java.util.*;
public class dbPOOL {
  Connection con;
  private boolean conFree = true;
  private String dbName = "java:comp/env/jdbc/connectDB";
  public dbPOOL() throws Exception {
       try  {              
                InitialContext ic = new InitialContext();
                DataSource ds = (DataSource) ic.lookup(dbName);
                con =  ds.getConnection();    
     } catch (Exception ex) { throw new Exception("Couldn't open connection to database: " + ex.getMessage());
  public void remove () {
         try {
             con.close();
        } catch (SQLException ex) { System.out.println(ex.getMessage());}
  protected synchronized Connection getConnection() {
         while (conFree == false) {
                 try {
                         wait();
                 } catch (InterruptedException e) {
              conFree = false;
              notify();
              return con;
    protected synchronized void releaseConnection() {
        while (conFree == true) {
                 try {
                    wait();
                 } catch (InterruptedException e) {
              conFree = true;
              notify();
}and my worker servlet connTest
package DATABASE;
import javax.naming.*;
import javax.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
import java.util.*;
public class connTest extends HttpServlet {  
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, SQLException, IOException {
         try {
                String selectStatement = "select * " + "from mt.Evendale_Web_Groups";
                getConnection();
                PreparedStatement prepStmt = con.prepareStatement(selectStatement);
                ResultSet rs = prepStmt.executeQuery();
                while (rs.next()) {
                   groupList gl = new groupList(rs.getString(1), rs.getString(2), rs.getString(3));
                prepStmt.close();
        } catch (SQLException ex) { throw Exception(ex.getMessage());}
            releaseConnection();
}When I try to compile the connTest servlet - I keep getting cannot find symbols errors on the methods. How do I fix this?

Which errors exactly?
Try something like this:
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
dbPOOL db = null;     
try {               
String selectStatement = "select * " + "from mt.Evendale_Web_Groups";
db = new dbPOOL();        
Connection con = db.getConnection();               
PreparedStatement prepStmt = con.prepareStatement(selectStatement);               
ResultSet rs = prepStmt.executeQuery();               
while (rs.next()) {                                    
   // process your rs                      
prepStmt.close();           
} catch (Exception ex) {
} finally {
    if (db != null)
         db.releaseConnection();             
}Simply change the package name to something else. But don't forget to import your dbPOOL class since it is now located in a diff package. Also be aware of coding standards when naming your classes and packages.

Similar Messages

  • Calling a method from another file

    This is pretty basic stuff but i can't seem to get it right. I am calling a method from another file. The other file IS located in the same folder BUT when i compile i get errors
    "cannot find symbol" <===referring to limit and sieve i believe.
    The method name is "sieve" the file name is "PrimeSieve2008" and "limit" is the variable in brackets in the real method.
         public static void main (String [] args) {
    final int [] PRIMES;
    int sieve = PrimeSieve2008.sieve(limit);
         PRIMES = sieve(getValidInt());
              for (int j = 0; j<PRIMES.length; j++) {
                   System.out.println("Prime[" + j + "] = " + PRIMES[j]);
    Is "int sieve = PrimeSieve2008.sieve(limit)" the wrong way to call a file?
    Thanks a million,
    Alex
    Edited by: Simplistic2099 on Apr 3, 2008 7:47 PM
    Edited by: Simplistic2099 on Apr 3, 2008 7:49 PM

    Simplistic2099 wrote:
    the other method runs fine:
    "public static int[] sieve(final int limit){
    int candidate; // possible prime
    int count; // no. of primes found
    boolean[] mayBePrime = new boolean[limit+1];
    // remaining possibilities
    final int[] PRIMES; // array to return
    // initialize mayBePrime
    for ( int j = 0 ; j <= limit ; j++ ) {
    mayBePrime[j] = true;
    mayBePrime[0] = mayBePrime[1] = false;
    // apply sieve, and count primes
    candidate = 2;
    count = 0;
    while ( candidate <= limit ) {
    if ( mayBePrime[candidate] ) {
    count++;
    for ( int j = 2 * candidate ; j <= limit ; j += candidate ) {
    mayBePrime[j] = false;
    } // end for
    } // end if
    candidate++;
    } // end while
    // fill up new array with the primes found
    PRIMES = new int[count];
    count = 0;
    for (int j = 2 ; j <= limit ; j++ ) {
    if ( mayBePrime[j] ) {
    PRIMES[count] = j;
    count++;
    } // end if
    } // for
    return PRIMES;
    } // sieve
    I really am clueless here.in this one you are passing in limit.
    in the other one you are getting limit from somewhere outside of main.

  • Calling a method from another class... that requires variables?

    I'm calling a method from another class to change the date (its a date object) in another class.
    I keep getting the error 'setDate(int,int,int) in Date cannot be applied to ()'
    My code is:
    public int changeDate()
         cycleDate.setDate();
    }I'm guessing I need to pass 3 parameters (day, month, year), but I'm not sure how! I have tried, but then I get errors such as ')' expected?
    Any ideas! :D

    f1d wrote:
    I'm calling a method from another class to change the date (its a date object) in another class.
    I keep getting the error 'setDate(int,int,int) in Date cannot be applied to ()'
    My code is:
    public int changeDate()
    cycleDate.setDate();
    }I'm guessing I need to pass 3 parameters (day, month, year), seems that way from the error you posted
    but I'm not sure how!
    setDate(16, 6, 2008);
    I have tried, but then I get errors such as ')' expected?
    Any ideas! :Dyou need to post your code if you're getting specific errors like that.
    but typically ')' expected means just that, you have too many or not enough parenthesis (or in the wrong place, etc.)
    i.e. syntax error

  • Help on Calling a method from another class

    how can i call a method from another class.
    Class A has 3 methods
    i just want to call only one of these 3 methods into my another class.
    How can I do that.

    When i am trying this
    A a=new A;
    Its calling all the methods from class A. I just want
    to call a specfic method.How can it be done?When i am trying this
    A a=new A();
    Its calling all the methods from class A. I just want to call a specfic method.How can it be done?

  • How do you call a method from  another class without extending as a parent?

    How do you call a method from another class without extending it as a parent? Is this possible?

    Why don't you just create an instance of the class?
    Car c = new Car();
    c.drive("fast");The drive method is in the car class, but as long as the method is public, you can use it anywhere.
    Is that what you were asking or am I totally misunderstanding your question?
    Jen

  • How to call a method from another class

    I have a problem were i have to call a method from another class. What is the command line that i have to use. Thanks.

    Here's one I wipped up in 10 minutes... Cool!
    package forums;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import krc.utilz.io.Filez;
    import java.io.FileNotFoundException;
    class FileDisplayer extends JFrame
      private static final long serialVersionUID = 0L;
      FileDisplayer(String filename) {
        super(filename);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setSize(600, 800);
        JTextArea text = new JTextArea();
        try {
          text.setText(Filez.read(filename));
        } catch (FileNotFoundException e) {
          text.setText(e.toString());
        this.add(text);
      public static void main(String args[]) {
        final String filename = (args.length>0 ? args[0] : "C:/Java/home/src/forums/FileDisplayer.java");
        try {
          java.awt.EventQueue.invokeLater(
            new Runnable() {
              public void run() {
                new FileDisplayer(filename).setVisible(true);
        } catch (Exception e) {
          e.printStackTrace();
    Filez.read
       * reads the given file into one big string
       * @param String filename - the name of the file to read
       * @return the contents filename
      public static String read(String filename) throws FileNotFoundException {
        return Filez.read(new FileReader(filename));
       * Reads the contents of the given reader into one big string, and closes the reader.
       * @param java.io.Reader reader - a subclass of Reader to read from.
       * @return the whole contents of the given reader.
      public static String read(Reader in) {
        try {
          StringBuffer out = new StringBuffer();
          try {
            char[] bfr = new char[BFRSIZE];
            int n = 0;
            while( (n=in.read(bfr,0,BFRSIZE)) > 0 ) {
              out.append(bfr,0,n);
          } finally {
            if(in!=null)in.close();
          return out.toString();
        } catch (IOException e) {
          throw new RuntimeIOException(e.getMessage(), e);
      }Edited by: corlettk on Dec 16, 2007 1:01 PM - dang [code [/tags][                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Calling repaint method from another class

    My question in a very simple form :
    how do I call repaint mathod from another class.
    e.g: Let's say class "A.java" is a JFrame .
    Class "B.java" is a JPanel which is added to the JFrame above.
    Class "C.java" is a JDialog containing some JButtons.
    How do I call the repaint method from the class "C.java".
    Thank you in advance!!

    My question in a very simple form :
    how do I call repaint mathod from another class.
    e.g: Let's say class "A.java" is a JFrame .
    Class "B.java" is a JPanel which is added to the JFrame above.
    Class "C.java" is a JDialog containing some JButtons.
    How do I call the repaint method from the class "C.java".
    Thank you in advance!!

  • Can't add list element when calling a method from another class

    I am trying to call a method in another class, which contains code listmodel.addElement("text"); to add an element into a list component made in that class.
    I've put in System.out.println("passed"); in the method just to make sure if the method was being called properly and it displays normally.
    I can change variables in the other class by calling the method with no problem. The only thing I can't do is get listmodel.addElement("text"); to add a new element in the list component by doing it this way.
    I've called that method within it's class and it added the element with no problem. Does Java have limitations about what kind of code it can run from other classes? And if that's the case I'd really like to know just why.

    There were no errors, just the element doesnt get added to the list by doing it this way
    class showpanel extends JPanel implements ActionListener, MouseMotionListener {
           framepanel fp = new framepanel();
           --omitted--
         public void actionPerformed(ActionEvent e){
                  if(e.getSource() == button1){
                       fp.addLayer();
    /*is in a different class file*/
    class framepanel extends JPanel implements ActionListener{
            --omitted--
         public void addLayer(){
              listmodel.addElement("Layer"+numLayer);
              numLayer++;
    }

  • Calling a method from another class or accessing a component from another

    Hi all
    im trying to make a find/replace dialog box
    my main application form has a jtextpane and when i open up the find and replace dialog box it has two textboxes (find and replace)
    now i have the code to do the finding on my jtextpane but how do i call that code to do the find method?
    I have tried having the code in my main application class but then how do i call that method from my dialog box class?
    ive also tried having the code in my dialog box class, but then how to i tell it to work on my jtextpane which is in my main ap class?

    well if someone had been nice enough to provide me
    with a tutorial i wouldnt have gotten into this
    muddle, no need to be rude is there!I'm not rude. And you also wouldn't have gotten into the muddle if you searched yourself. This site provides many very good tutorials about all kinds of stuff.
    http://java.sun.com/docs/books/tutorial/java/javaOO/classes.htmlAmong other things, it mentions that "static" defines everything that belongs to a class, as opposed to an object.

  • ABAP Objects : calling one method from another class

    Hi,
    Can you please tell me how to call method from one class or interfce to another class.The scenario is
    I have one class CL_WORKFLOW_TASK, this class have interface IF_WORKFLOW_TASK & this interface have method IF_WORKFLOW_TASK~CLOSE. Now my requirement is ,
    There is another class CL_WORKFLOW_CHAIN ,this class have interface IF_WORKFLOW_CHAIN & this interface have method IF_WORKFLOW_CHAINCLOSE_ALL_PREDECESSORS. Now i have to write my code in this method but i have to use IF_WORKFLOW_TASKCLOSE method for closing the task.
    Can you please give me the code for the above .
    Please waiting for reply.

    Hi,
    You can use the concept of INHERITANCE  in this scenario.By using this concept, you can call all the public and protected  methods of class CL_WORKFLOW_TASK  in the required calss CL_WORKFLOW_CHAIN as per your requirement.
    Go through the  Introdctory(INHERITANCE) programming from this SAPHELP link.
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    I hope, it will help in you inresolving your problem.
    by
    Prasad GVK.

  • Simple enough but... calling a method from another class

    Hi all,
    I know it's simple enough, although I can't see where I'm going wrong for some reason. Basically I've got a class which extends JPanel but when I try to call one of its methods from my main class I get an error. The relevant code (I hope) is:
    Main.java
    import java.awt.BorderLayout;
    import javax.swing.UIManager;
    public class Main extends JFrame implements ActionListener {
         JFrame frame;
         public static JPanel statusBar;
         public Main() {
              // Add a status bar
              statusBar = new StatusBar();
              mainPanel.add( statusBar, BorderLayout.SOUTH );
              setContentPane( mainPanel );
         public static void setStatusBarText( String s ) {
              statusBar.setStatusText("Test");
    StatusBar.java
    import java.awt.Color;
    import javax.swing.SwingConstants;
    public class StatusBar extends JPanel {
         private int barWidth;
         private static JLabel status;
         public StatusBar() {
              super();
              //barWidth = Main.getProgramWidth();
              //setPreferredSize( new Dimension(barWidth,22) );
              setLayout( new FlowLayout( FlowLayout.LEADING ) );
              setBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(160,160,160) ) );
              status = new JLabel("Test", SwingConstants.LEFT);
              //status.setVerticalAlignment( SwingConstants.CENTER );
              add( status );
         protected void setStatusText( String s ) {
              status.setText( s );
              revalidate();
    }The "statusBar.setStatusText("Test");" call in the main class file doesn't work and I get the error:
    >
    cannot find symbol
    symbol : method setStatusText(java.lang.String)
    location: class javax.swing.JPanel
    statusBar.setStatusText("Test");
    >
    Any ideas what I'm doing wrong? I created an instance of the StatusBar class called statusBar, then I use this to call the setStatusText() method (via statusBar.setStatusText()) which I thought was all correct, then it doesn't work? Even if there's an easier way to do what I want to achieve (i.e. update a JLabel from the 'central' main class file instead of setting the JLabel to static and having every class call it directly), I'd appreciate knowing where I'm going wrong here nonetheless.
    Many thanks,
    Tristan

         public static JPanel statusBar;
         public static void setStatusBarText( String s ) {
              statusBar.setStatusText("Test");
    >
    cannot find symbol
    symbol : method setStatusText(java.lang.String)
    location: class javax.swing.JPanel
    statusBar.setStatusText("Test");
    >The type of variable statusBar is JPanel. That's all the compiler takes into account. It's irrelevant that at some point in the program the type of the object pointed to by this variable is a subclass of JPanel (because at another point it might be an instance of another subclass, or of JPanel itself.

  • How call a method from another class

    i make three class.class A,class B and class C.
    class A have One button.
    Class B have a action listener of that button.
    class c have a metod like
    public void test(){     }
    how can i call a method in class b from class c;
    is it necessary to pass the class a or b through the constructor of class c or another way to call the method.

    public class Foo
        public static void main(String[] args)
            Bar.staticFn();
            Bar b = new Bar();
            b.memberFn();
    class Bar
        public void memberFn()
            System.out.println("memberFn");
        public static void staticFn()
            System.out.println("staticFn");
      }

  • Calling a method from another class while in a seperate class

    Hello
    I am currently TRYING to proramme a simple alarm clock program, The way it has had to be set out is that there are two classes one is called ClockDisplay which is just the clock and the one i have had to create is called AlarmDisplay
    I am trying to write code so that when the String alarmdisplayString(this is located in the alarm class which i am typing this code) is the same as String displayString the system will print out something like "Beep wake up" So far i have this code but i cannot figue out what to put to reference the method from the ClockDisplay class while codingi n the AlarmDisplay class
    if(alarmdisplayString = DONT KNOW WHAT TO PUT HERE) {
    system.out.println ("DING WAKE UP");
    Any help would be great!
    Thanks

    That makes sense i have put in this code
    private void Alarmtone()
    ClockDisplay displayString = new ClockDisplay();
    if (alarmdisplayString == ClockDisplay.displayString){
    system.out.println ("DING WAKE UP");
    displayString is the method in the ClockDisplay Class
    alarmdisplayString is the method in the AlarmDisplay class
    I get the error message "non-static variable displayString cannot be referenced from a static context
    Thanks for the help so far :D

  • Calling a method from another class. Please Help!!

    Here is my full program. Like I said in my last post. I am having trouble calling the baseMakesError1 method. This method is called in the subcallsbase1 method. Also, it would be of great help if you could look for any other errors with with my program. Thank you so much. I really appreciate it.
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    public class ThomasR11
    String sy;
    public static void main(String[] args)
    System.out.println("(main): Ryan Thomas, file ThomasR11: Exceptions");
    SubRT obj3;
    SubRT obj4;
    String sX;
    String x;
    String s;
    String sY;
    try
    ThomasR11 obj1=new ThomasR11();
    catch(NullPointerException NPE)
    System.err.println("Null Pointer Exception");
    ThomasR11 obj2=new ThomasR11("Hello");
    System.out.println("This is the last statement in main");
    public ThomasR11()
    SubRT obj3= new SubRT();
    obj3.subCallsBase1();
    public ThomasR11(String sY)
    throws FileNotFoundException
    SubRT obj4= new SubRT();
    obj4.subError2();
    obj4.subError3(sY);
    private static class BaseRT
    public BaseRT()
    System.out.println("In BaseRT constructor= " + this);
    public void baseMakesError1(int value0)
    System.out.println("In BaseRT constructor, about to throw exception");
    if (value0==0)
    throw new NullPointerException("NullPointerException");
    private class SubRT extends BaseRT
    SubRT subNull;
    public SubRT()
    System.out.println("In SubRT constructor before call to aMakes an error= " +
    "\n SubRT constructor= " + this);
    public void subCallsBase1()
    try
    System.out.println("Calling the method baseMakeserror1");
    baseMakesError1(subNull);<---------------------This is where I am getting the error it says "ThomasR11.java [79:1] baseMakesError1(int) in ThomasR11.BaseRT cannot be applied to (ThomasR11.SubRT)"
    catch(NumberFormatException NFE)
    System.err.println("\nNumber Format Exception");
    catch (NullPointerException NPE)
    System.err.println(NPE.getMessage() + "\n");
    System.err.println(NPE.toString() + "\n");
    throw NPE;
    public void subError2()
    try
    BufferedReader in = new BufferedReader( new FileReader( "c:/xx/xx.xx" ) );
    catch(NullPointerException NPE)
    System.out.println("Null Pointer Exception");
    catch (FileNotFoundException FNFE)
    System.err.println("FileNotFoundException");
    public void subError3( String sX)
    try
    System.out.println("Hello");
    System.out.println (sX.length());
    catch(NullPointerException NPE)
    System.err.println("Null Pointer Exception");

    "ThomasR11.java [79:1] baseMakesError1(int) in ThomasR11.BaseRT cannot be applied to (ThomasR11.SubRT)"
    ...this error is telling out that you wrote baseMakesError1 to accept an "int" as an argument, and you are trying to pass it an instance of the ThomasR11.SubRT class. You either have to change baseMakesError1 to accept a SubRT as an argument, or change your call to pass an integer.

  • Calling a method from another Java file.

    I think I'm doing this right, but I'm obviously going wrong somewhere.
    In order to not have one big long java file, I've created one main one to execute the program, and another to do some of the functions. I'm using eclipse, btw.
    In the main file, I have
    currentTB = getActiveTB(playerArea);If it works, it should get send the player area variable to the getActiveTB method, and store the value it returns in the currentTB variable, right?
    In the other file, I have;
    package scenes;
    public class sceneIndex {
         private TerrainBlock getActiveTB(String areaCode) {
              TerrainBlock tBlock = new TerrainBlock();
                     **DOES STUFF**
              return tBlock;
    }I have it set up so the second file is in the source folder "resources" and the package "scenes." The problem is I'm not calling it properly. I'm missing something simple, I think. The only error I'm getting is;
    The method getActiveTB(String) is undefined...
    Where am I screwing up?
    EDIT: Yeah, I'm a rookie here trying to figure it out on my own. My computer science courses, so far, conveniently all consist of just one big java file. Easier to write, sure, but not very efficient/organized.
    Message was edited by:
    SuckerPunch

    Yeah, so this is still pissing me off. I'm not sure what else to do. I've tried this a million different ways, in both eclipse and netbeans. Whatever. Here's the code, I'd love it if someone could point out the boneheaded mistake I'm making. I'm getting a little frustrated at being stuck on such a simple problem.
    Main.javaimport com.jme.app.BaseGame;
    import com.jme.input.KeyBindingManager;
    import com.jme.input.KeyInput;
    import com.jme.math.Vector3f;
    import com.jme.renderer.Camera;
    import com.jme.renderer.ColorRGBA;
    import com.jme.scene.Node;
    import com.jme.system.DisplaySystem;
    import com.jme.system.JmeException;
    import com.jme.util.Timer;
    import com.jmex.terrain.TerrainBlock;
    import resources.*;
    public class Main extends BaseGame {
         /* General Variable Declaration */
         private String scene;   // Tells application which scene to load, default loads default scene
         private int width, height, depth, freq; // Creates variables to store information
         private boolean fullscreen;             // on the user's window
         private Camera playerCam; // Defines the main camera for the player, first person view
         private Timer timer; // Creates a timer to be used for FPS calculations
         private Node currentScene; // The basis for building the scene the player is in
         private TerrainBlock currentTB; // This variable holds the current landscape
         private String playerArea = new String("initial"); // Contains the string
                                                                        // code for the scene
                                                                        // the player is in,
                                                                        // defaults to the opening scene, unless changed by
                                                                        // the player loading their game
            public static void main(String[] args) {
              /* Initializes and Starts the Applications. */
              Main app = new Main();
              app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG, Main.class.getClassLoader().getResource("img/spunch.jpg"));
              app.start();
         protected void update(float interpolation) {
         protected void render(float interpolation) {
         protected void initSystem() {
               * Application initialization properties (window, camera, renderer, key
               * bindings, etc)
              // Stores variables for window properties
              width = properties.getWidth();
              height = properties.getHeight();
              depth = properties.getDepth();
              freq = properties.getFreq();
              fullscreen = properties.getFullscreen();
              // Assigns renderer and creates game window
              try {
                   display = DisplaySystem.getDisplaySystem(properties.getRenderer());
                   display.createWindow(width, height, depth, freq, fullscreen);
                   playerCam = display.getRenderer().createCamera(width, height);
              } catch (JmeException e) {
                   e.printStackTrace();
                   System.exit(1);
              // Sets background to black, should never be seen anyway
              display.getRenderer().setBackgroundColor(ColorRGBA.black);
              // Initializes the camera
              playerCam.setFrustumPerspective(45.0f, (float) width / (float) height,
                        1, 1000);
              Vector3f loc = new Vector3f(250.0f, 100.0f, 250.0f);
              Vector3f left = new Vector3f(-0.5f, 0.0f, 0.5f);
              Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
              Vector3f dir = new Vector3f(-0.5f, 0.0f, -0.5f);
              // Moves and orients the camera
              playerCam.setFrame(loc, left, up, dir);
              // Update the camera since it has been changed
              playerCam.update();
              // Create a timer for FPS updates
              timer = Timer.getTimer();
              // Assign the camera as the primary display in the application
              display.getRenderer().setCamera(playerCam);
              // Initialize the escape key as a way to exit the program
              KeyBindingManager.getKeyBindingManager().set("exit",
                        KeyInput.KEY_ESCAPE);
         protected void initGame() {
              /* Game initialization */
              display.setTitle("Slumlords"); // Displays title in window
                    SceneIndex sIndex = new SceneIndex();
              currentTB = sIndex.getActiveTB(playerArea);
              currentScene.attachChild(currentTB);
              currentScene.updateGeometricState(0.0f, true);
              currentScene.updateRenderState();
         protected void reinit() {
         protected void cleanup() {
    }SceneIndex.javapackage resources;
    import javax.swing.ImageIcon;
    import com.jme.bounding.BoundingBox;
    import com.jme.image.Texture;
    import com.jme.math.Vector3f;
    import com.jme.scene.state.TextureState;
    import com.jme.system.DisplaySystem;
    import com.jme.util.TextureManager;
    import com.jmex.terrain.TerrainBlock;
    import com.jmex.terrain.util.MidPointHeightMap;
    import com.jmex.terrain.util.ProceduralTextureGenerator;
    public class SceneIndex {
         private DisplaySystem display;
         public TerrainBlock getActiveTB(String areaCode) {
              TerrainBlock tBlock = new TerrainBlock();
              if (areaCode == "initial") {
                   // Generates random terrain data
                   MidPointHeightMap heightMap = new MidPointHeightMap (64, 1.0f);
                   // Scale the data
                   Vector3f terrainScale = new Vector3f(4, 0.0575f, 4);
                   // Create the terrain block
                   tBlock = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale, heightMap.getHeightMap(), new Vector3f(0, 0, 0), false);
                   tBlock.setModelBound(new BoundingBox());
                   tBlock.updateModelBound();
                   // Creating a blended texture based on the height map
                   ProceduralTextureGenerator pTexture = new ProceduralTextureGenerator(heightMap);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/grass.gif")), -128, 0, 128);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/dirt.jpg")), 0, 128, 255);
                   pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/granite.jpg")), 128, 255, 384);
                   pTexture.createTexture(64);
                   // Assigning the texture to the terrain
                   TextureState tState = display.getRenderer().createTextureState();
                   Texture t1 = TextureManager.loadTexture(pTexture.getImageIcon().getImage(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
                   tState.setTexture(t1, 0);
                   tBlock.setRenderState(tState);
              return tBlock;
    }Again, I've tried this a few different ways, and I either get a "Could Not Find Symbol" error referring to the getActiveTB(playerArea); in Main, or it just says java.lang.NoClassDefFoundError: and Exception in thread "main".
    Whatever.

Maybe you are looking for

  • Error on HTML Parser

    Hi, I'm trying to parse a HTML page but I always get the same error, which is the following exception: javax.swing.text.ChangedCharSetException In the class ParserCallback I'm using the method handleError and it shows: req.att contentmeta? ioexceptio

  • Storing data - best practice?

    Hi, I wonder if there is any best practice to store data in my EP6.0 portal? For instance, in a standard website if you have a list of events, each event can be stored in a related sql-database and can then be fetched and updated whenever necessary.

  • Tables in Formscentral

    How do I create a table with text fields so that the table can be completed in Adobe Pro XI Formscentral. The table must have four columns and seven rows - where the first row and the first column will be used for headings. The rest of the table must

  • GRN to AP Invoice Doc total changes

    Hi All We have a problem with the Invoicing AP Invoices from GRV's, the document total changes and leaves the document open. I copied one GRV with doc total R 9215.79  to AP Invoice and the total was R 9215.41. The only thing that I changed was the D

  • Where/how can I find hardware acceleration?

    Since I started using Firefox the text fonts are really, really thin and hard to read. So I went thru the questions & answers posted in the help forum. I found a very good answer - it says: Turn off hardware acceleration in Options. I cud not find it