Eclipse Jar creating ? main-class error

hello

i am news to java/eclipse and i wrote a litte programm with jogl.

now i want to test it on other systems so i try to complie it
to an jar file , the Export works inside eclipse but at the end
i got my jar file in an folder and when starting i get the message
:[could not find main-class. programm will exit]

what is my error?

my steps:
->export
->selecting jar file as target
->selecting the jar file specs

->selecting the main class

thats all, what is missing?
inside eclipse my programm works perfect?

thanks for any help

open up the jar file and see what is inside the manifest… has eclipse generated the correct details?

also make sure that your expected class file which has the main method is in JAR

manifest file (manifest.ml)

Manifest-Version: 1.0
Main-Class: fso_wars

in export i put manifest.ml

i have no idea where to search inside eclipse.
i used c++ with microsoft vs and there was no big trouble
compiling projects and get them to run. eclipse and java is
new to me… manifest files , native libarys…
inside eclipse all is fine…so i did not understand why the export
is so complicated

what i did not understand:
in export there is the point:
select the class of the application entry point
main class [ ]

there i can only select my “main file” and there is all inside,
it only one java file with the whole program inside,
i select it and the the jar says when starting at end of export:
main class is missing ??!?!?!

thanks for help

…the most time i sit and try to translate the words to german to understand

Does your “main file” (fso_wars) have a main method? (i.e. public static void main(String[] args) …) If not then how are you running it within Eclipse?

A couple of things to try. Firstly open you your .jar file in WinZip and check your main file is actually there.

If so, when you Export to your .jar file make sue you select “Generate the manifest file” from Eclipse and select the Main Class (ie. your file with your main method)…

Afterwards you should be able to run quite easily using java -jar myjar.jar from DOS

hello

i look into the fso_wars.jar and my main file is inside
->
folder [gfx] - my textures
folder [META-INF]
fso_wars.class
fso_wars.java
.classpath
.project
fso_wars
manifest.mf

‘when you Export to your .jar file make sue you select “Generate the manifest file” from Eclipse and select the Main Class (ie. your file with your main method).’

thats the way i do

using the command promt brings in dos the same message
like direct in windows

D:\a_game> java -jar fso_wars.jar
Failed to load Main-Class manifest attribute from
fso_wars.jar

what could it be?

Sorry dont know then… Ive been using Eclipse -> Export .jar for years without any problems…

Try googling “Failed to load Main-Class manifest attribute from”, seems like its a common problem. Good luck!

in the night i try to use the tool
jsmooth i found with google

it puts jar into an window wrapper

no chance, even that is not working

whats wrong with java? is eclipse the wrong tool?

what can i do more ?!?! please help

Could you post the contents of your manifest file?
Are you sure your manifest.mf file is inside the META-INF folder (in your post it looks like it’s in the root?)

i look into the META-INF folder of the fso_wars.jar

there is a MANIFEST.ML (good to know now where the manifest file should be)


Manifest-Version: 1.0
Sealed: true
Main-Class: fso_wars

and there is a refactorings.xml file in the meta-inf folder

[quote]there is a MANIFEST.ML (good to know now where the manifest file should be)
[/quote]
manifest.mf or manifest.ml?

Is there any way you can upload your jar somewhere?

oops not .ml its a manifest.mf

is it possible that java got a problem with the _ in fso_wars?

i uploaded an new version , renamed the whole project to fso

www.unterhaltungsuniversum.de/fso.jar

i create an example with the help tool, and this dos thing works after export !

public class hello {

/**
 * @param args
 */
public static void main(String[] args) {
	// TODO Auto-generated method stub

	System.out.println("Hello world!");
}

next test is an example of wikipedia for jogl

import javax.swing.;
import javax.media.opengl.
;
import com.sun.opengl.util.GLUT;

public class JoglTest extends JFrame
{
GLCanvas canvas;

public JoglTest()
{
GLCapabilities cap = new GLCapabilities();

canvas = new GLCanvas(cap);

canvas.addGLEventListener(new SceneView());

getContentPane().add(canvas);

setTitle("Simples Jogl-Beispiel");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 400);
setVisible(true);    

}

class SceneView implements GLEventListener
{
public void init(GLAutoDrawable arg0)
{
GL gl = arg0.getGL();
float l_position[] = {100.0f, 100.0f, 200.0f, 1.0f};

  gl.glEnable(GL.GL_LIGHTING);
  gl.glEnable(GL.GL_LIGHT0);
  gl.glEnable(GL.GL_COLOR_MATERIAL);
  gl.glEnable(GL.GL_DEPTH_TEST);
  gl.glEnable(GL.GL_NORMALIZE);
  gl.glEnable(GL.GL_POLYGON_SMOOTH);
  gl.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, l_position, 0);  

  gl.glClearColor(0.7f, 0.7f, 0.7f, 0.0f);
              
  gl.glMatrixMode(GL.GL_PROJECTION);
  gl.glOrtho(-100, 100, -100, 100, -100, 100);

  gl.glMatrixMode(GL.GL_MODELVIEW);
  gl.glRotatef(35.0f, 1.0f, 0.0f, 0.0f);    // Rotation um die x-Achse
  gl.glRotatef(-25.0f, 0.0f, 1.0f, 0.0f);   // Rotation um die y-Achse
}


public void display(GLAutoDrawable arg0) 
{
  GL gl = arg0.getGL();
  GLUT glut =  new GLUT();
       
  gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
  gl.glColor3f(0.2f, 1.0f, 0.3f);
  glut.glutSolidTeapot( 50.0 ) ;
}


public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) 
{
}


public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) 
{
}

}

public static void main(String args[])
{
new JoglTest();
}
}

that does the same problem like my own program

could not find the main class

there must be any bug in the exporter

It’s a weird error…
I’m not seeing a problem in the manifest.

However, what I did notice is that the jogl binaries are not in the classpath, and there are no jogl dlls, so it also doesn’t start with “java -cp fso.jar fso” (albeit with a different error). That might be the cause (although the error is then quite misleading…)

It seems eclipse doesn’t take the referenced jar files in your project into account when exporting a jar.
What I would do is get it to run using ‘java -cp fso.jar;jogl.jar (etc…)’ and go from there.

One thing to keep in mind is that relying on the .jar extension isn’t such a good idea to begin with because programs like WinZip or something might steal the .jar association.

A better idea is to either provide .cmd and .sh files and such to make it run on the supported platforms, use something like JSmooth (windows only), or (my personal preference) using Java Web Start.
For Java Web Start, check out this tutorial: http://www.cokeandcode.com/webstarthowto (it covers a jogl application)

complicated stuff :wink:

i tryed jsmooth but the problem stays… the main-class error

at moment it dosnt matter to me on what system it runs…
the only thing that i want that it runs …no matter on what…
only one time that it start without eclipse

i come from c++ and there i only need to add the libs inside
the visual studio… the compiler do the job…
in java/eclipse is everything complicated

only for understanding:
the problem seems the jogl libs

i add them inside eclipse editor at buildpath/libarys …and there they work
(jogl.jar gluegen-rt.jar)

and i have left the .libs in my jogl installation folder
(jogl.lib jogl-awt.lib jogl-cg. gluegen-rt.lib)

ok:

what lib or what jar did i have to put where in the
workspace or in the final jar or something else
and what did i have to add inside the manifest.mf

in the final jar are my folders and the Meta-inf
,should i create there an folder libs and copy all inside (libs and jars)?

thanks for help… i am very confused

You could add a Class-Path line to your manifest file inside the jar and list the relative locations of the other jars you need to have available at runtime

META-INF /MANIFEST.MF

Manifest-Version: 1.0
Main-Class: fso
Class-Path: jogl.jar gluegen-rt.jar

the jogl.jar and the gluegen.jar are in the root to the fso.jar

result: could not find main class . program will exit

That won’t work, it will try to load those jars in the same directory as fso.jar.

It’ll be easier to test with ‘java -cp fso.jar;jogl.jar;gluegen-rt.jar fso’ as it might give you better error messages. Starting it this way also doesn’t require the manifest at all.
Also make sure your program can load the required .dll files (put them also in the same directory).

ok. i work on the problem the last days and now i fall over something
much better… instead using eclipse i use now netbeans

this ide do the job perfect

ok, only a litte thing in netbeans is with the heapspace,
when import my large float vars it gets
on netbeans the heap space error (in eclipse it was okay)

float [] heighter = new float[2000000]; //yes i need something large like this :wink:

but my application runs now direct (without the landscpace float error var)
and its direct build for 8 other sytems (mac,solaris,linux etc) thats more i dream of