How would I run a Java application I have made?
-JR-
Printable View
How would I run a Java application I have made?
-JR-
I suppose you are looking for more than:
java YourClass
or
javaw YourClass
So you might want to check out the deployment post
http://vbforums.com/showthread.php?s=&threadid=70223
Well, I'm one of those who have taken Java in school, loved it and tried to take the development home. Well, I got the developer kit with the compiler and all that, and actually can compile java applets as well as applications. I have only written applications in school so far, and home I've only made a couple of applets. With them, you just need a browser to run them, but with applications you have to run them, they are stand alone. In school, I can just type "javac myProg.java" and then "java myProg". That's it. But home, it compiles, but when I try to do the "java" command, it gives meWhere the class would be in e:\java\game\game.classQuote:
Exception in thread "main" java.lang.NoClassDefFoundError: e:\java\game\game
Thank you so much for any help you could give me (I'm toast if I can't figure this out by Tuesday, it's for school and due then).
-JR-
Could I see the game source?
I took out some of the code, just some insignificant functions... this should be all you need to look it through. It compiles OK, there's just something wrong with running a java application...Code:import java.io.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class Game extends Frame implements KeyListener, WindowListener {
// Init stuff
int [] [] Level = new int [100] [100];
int topCorrection = 35; // Set the TOP and LEFT values of the place where the LEVEL will begin to be drawn
int leftCorrection = 16;
int xPos = 0;
int yPos = 0;
int tileSize = 20;
int oldX = 0;
int oldY = 0;
private BufferedReader inFile;
int movesTaken = 0;
int movesMax = 0;
boolean won = false;
public static void main (String [] args) {
Game thisGame = new Game();
thisGame.setSize (530,500);
thisGame.setVisible(true);
}
public Game () {
createMap1();
repaint();
setTitle("d a g a m e (c) j a r e w a r e");
this.addWindowListener(this);
this.addKeyListener (this);
}
public void update (Graphics g) {
setBackground(Color.white);
// Draw the level
// Draw the position of the player
drawPlayer();
if (movesTaken <= movesMax) { g.setColor(Color.green); } else { g.setColor(Color.red); }
g.fillRect(16,345,500,40);
g.setColor(Color.white);
g.fillRect(21,350,490,30);
g.setColor(Color.black);
g.drawRect(16,345,500,40);
g.drawRect(21,350,490,30);
g.drawString("Moves left: " + movesTaken + " / " + movesMax + ")",26,365);
//g.drawString("Player position, x = " + xPos + ", y = " + yPos + "",26,360);
if (won) {
g.setColor(Color.white);
g.fillRect(0,0,1000,1000);
g.setColor(Color.black);
g.drawString("YOU WON!", 100, 100);
}
}
public void keyTyped (KeyEvent e) { }
public void keyPressed (KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
if (Level[xPos+1][yPos] == 0 || Level[xPos+1][yPos] == 2 || Level[xPos+1][yPos] == 9) {
oldX = xPos;
oldY = yPos;
xPos++;
movesTaken++; }
}
else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
if (Level[xPos-1][yPos] == 0 || Level[xPos-1][yPos] == 2 || Level[xPos+1][yPos] == 9) {
oldX = xPos;
oldY = yPos;
xPos--;
movesTaken++; }
}
else if (e.getKeyCode() == KeyEvent.VK_UP) {
if (Level[xPos][yPos-1] == 0 || Level[xPos][yPos-1] == 2 || Level[xPos+1][yPos] == 9) {
oldX = xPos;
oldY = yPos;
yPos--;
movesTaken++; }
}
else if (e.getKeyCode() == KeyEvent.VK_DOWN) {
if (Level[xPos][yPos+1] == 0 || Level[xPos][yPos+1] == 2 || Level[xPos+1][yPos] == 9) {
oldX = xPos;
oldY = yPos;
yPos++;
movesTaken++; }
}
if (Level[xPos][yPos] == 9) { // The player has reached the goal!
won = true;
}
repaint();
}
public void keyReleased (KeyEvent e) { }
public void windowClosing(WindowEvent e) {
System.exit(0);
}
public void windowIconified(WindowEvent e) { }
public void windowOpened(WindowEvent e) { }
public void windowClosed(WindowEvent e) { }
public void windowDeiconified(WindowEvent e) { }
public void windowActivated(WindowEvent e) {
repaint();
}
public void windowDeactivated(WindowEvent e) { }
}
-JR-
What class was it complaining that it couldn't find? You probably have to set the CLASSPATH to point to your custom classes. You set it like the regular DOS PATH. There are posts here on that too. Good luck.