Jump to content
  • Advertisement
Sign in to follow this  

Java errors

This topic is 4103 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I get this error: C:\Users\mark\Desktop>java gametry.class Exception in thread "main" java.lang.NoClassDefFoundError: gametry/class Caused by: java.lang.ClassNotFoundException: gametry.class at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) Here's my source:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Gametry {
	private static void GUItry() {
		JFrame f = new JFrame("Game Window");
		JLabel emptyLabel = new JLabel("");
		emptyLabel.setPreferredSize(new Dimension(800,600));
		public static void main(String args[]) {
			javax.swing.SwingUtilities.invokeLater(new Runnable() {
				public void run() {
					public class ImageApplet extends JApplet {
		public void init() {
			Container content_pane = getContentPane();
			Image img = getImage (getCodeBase (), "Halo.jpeg");
			DrawingPanel drawing_panel = new DrawingPanel (img);
			content_pane.add (drawing_panel);

		class DrawingPanel extends JPanel {
		Image img;
		DrawingPanel (Image img)
		{this.img = img; }
		public void paintComponent (Graphics g) {
		super.paintComponent (g);
		int imgX = getSize ().width/2 - img.getWidth (this);
		int imgY = getSize ().height/2 - img.getHeight (this);
		g.drawImage (img, imgX, imgY, this);

Please help, i'm not sure what i've done wrone. :D

Share this post

Link to post
Share on other sites
Hi, run it with 'java Gametry' without the .class on the end and it works fine.

Share this post

Link to post
Share on other sites
You never added an Image to your JFrame. You only added a DrawingElement to your applet class, which never runs, since you launch the "Gametry" class and not the applet.

I am confused why you have an applet and a JFrame.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!