I've been programming in Java for a few years now, and I've always wanted to be able to run my programs on computers without the JDK installed. I've been trying to make an executable .jar file, and it seems to work on my computer(the one with JDK installed). However, as soon as I put it on another computer, it stops working and gives me an error: main class not found, program will close.

I've tried it by making the jar through Eclipse and through the command line, and on 2 seperate other computers, and both times I've gotten errors there and its worked fine on this computer. Both computers have Java Platform SE Binary installed and set (automatically) as the default program to open .jar files, but I'm not quite sure if thats the JRE or whatever's needed for this to work. (EDIT: that seems to be the program associated with .jar files on the computer that works, as well)

I've also tried a bunch of programs that supposedly make .exe files out of .jar files, and none of those seem to work either. If it matters, here's the code I'm using for testing:

package org.TotalBeginner.Tutorial;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
public class TestClass extends JFrame
	Painter p = new Painter();
	public static void main(String[]args)
		new TestClass();
	public TestClass()
	public class Painter extends JPanel
		public void paintComponent(Graphics page)

Edited 4 Years Ago by firecy: n/a

I've also tried accessing the .jar file on the non-working computers through the command line by typing "java -jar TestJar.jar", and I get this error: unsupportedClassVersionError and unsupported major minor error 51.0. Does that mean that the other computer's java is outdated? or what?

You don't need a JDK to execute a jar file, you do need a JRE.

unsupported major minor error 51.0.

The source was compiled with 1.7 but the java program is an older version.
Either compile the source with 1.6 or execute the jar file with 1.7

This article has been dead for over six months. Start a new discussion instead.