Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Eclipse Jar creating ? main-class error  (Read 4212 times)
0 Members and 1 Guest are viewing this topic.
Offline Therion__

Junior Member





« Posted 2008-09-20 21:48:57 »

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



Offline moogie

JGO Knight


Medals: 12
Projects: 6
Exp: 10 years


Java games rock!


« Reply #1 - Posted 2008-09-21 01:11:52 »

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
Offline Therion__

Junior Member





« Reply #2 - Posted 2008-09-21 13:08:42 »

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




Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline steveyO
« Reply #3 - Posted 2008-09-21 15:32:33 »

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

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline Therion__

Junior Member





« Reply #4 - Posted 2008-09-21 17:21:28 »

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?


Offline steveyO
« Reply #5 - Posted 2008-09-21 22:37:56 »

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!

https://play.google.com/store/apps/details?id=com.bullsquared.alggame Annoying Little Gits (Android)
www.bullsquared.com   Play java (applet) games! www.chessclockpro.com Free Online Chess Clock
Offline Therion__

Junior Member





« Reply #6 - Posted 2008-09-22 09:14:57 »

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

 
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #7 - Posted 2008-09-22 10:09:24 »

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?)

Offline Therion__

Junior Member





« Reply #8 - Posted 2008-09-22 10:20:42 »

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


Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #9 - Posted 2008-09-22 14:29:31 »

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

manifest.mf or manifest.ml?

Is there any way you can upload your jar somewhere?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Therion__

Junior Member





« Reply #10 - Posted 2008-09-22 15:21:22 »

oops not .ml    its a manifest.mf


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

 
Offline Therion__

Junior Member





« Reply #11 - Posted 2008-09-22 15:58:33 »

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

www.unterhaltungsuniversum.de/fso.jar
Offline Therion__

Junior Member





« Reply #12 - Posted 2008-09-22 16:23:05 »

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
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #13 - Posted 2008-09-22 20:32:29 »

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...)

Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #14 - Posted 2008-09-22 20:54:12 »

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)

Offline Therion__

Junior Member





« Reply #15 - Posted 2008-09-22 21:39:55 »

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






 




Offline Wildern

Junior Member





« Reply #16 - Posted 2008-09-22 22:01:10 »

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
Offline Therion__

Junior Member





« Reply #17 - Posted 2008-09-23 08:19:51 »

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
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #18 - Posted 2008-09-23 13:39:10 »

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).

Offline Therion__

Junior Member





« Reply #19 - Posted 2008-09-25 08:50:46 »

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





Offline cylab

JGO Ninja


Medals: 38



« Reply #20 - Posted 2008-09-25 12:07:25 »

Quote
ok, only a litte thing in netbeans is with the heapspace,

- go to the "Projects" tab in the Netbeans main window
- right-click on your project and select "Properties"
- switch to the "Run" category
- enter "-Xmx256m" in the "VM Options" field

This way you set the maximum heap space to 256mb.

Mathias - I Know What [you] Did Last Summer!
Offline Therion__

Junior Member





« Reply #21 - Posted 2008-09-25 19:16:51 »

much much much thanks to you all


Smiley


all work perfect now Smiley

Smiley Smiley Smiley Smiley Smiley
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (24 views)
2014-07-24 01:59:36

Riven (22 views)
2014-07-23 21:16:32

Riven (18 views)
2014-07-23 21:07:15

Riven (21 views)
2014-07-23 20:56:16

ctomni231 (49 views)
2014-07-18 06:55:21

Zero Volt (45 views)
2014-07-17 23:47:54

danieldean (36 views)
2014-07-17 23:41:23

MustardPeter (39 views)
2014-07-16 23:30:00

Cero (54 views)
2014-07-16 00:42:17

Riven (54 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!