Main class not found (oh its there, alright)

I am trying to run an executable jar I created using Netbeans. I am using JOGL, and have those files referenced correctly in the ClassPath setting in the Manifest file. The main class is also correctly referenced in the Manifest file. Starting the jar sort of works. It creates a blank window the same size as the program should be. But nothing happens after that. I tried running it from the command line so errors would be printed… but nothing printed.

Just recently I figured out how to use the jdb (I’m not a hardcore programmer- it’s a hobby I only indulge in every few months or so), and saw the error. Apparently the program cannot find my main class. As I said, it is referenced correctly in the the automatically generated Manifest file.

Now I know this has been posted here before, and all over the web, but I’ve never, ever found an answer that does anything. I’ll provide more info if it’s needed, but it’d be great if someone who’s had and solved this problem could post.

Thanks, JavaGaming.

Does your main class have:


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

And the class / manifest should look like:


public class MainClass

Manifest:


Main-Class: MainClass


Don’t forget the blank newline at the end. If your main class is automatically generated, you probably don’t need to worry about that part.

I double checked (more like triple-triple-quadruple checked by now) and yes it’s all on the up-and-up. Everything’s typed out correctly and the Manifest file is formatted correctly.

Then obviously Java finds your main-class! How else can it create your window? It just crashes a bit later…

If you don’t see anything on the commandline, try to start your app with:
System.out.println("Started!");
That should end up on the commandline.

If no exception is dumped on the console, you probably caught some exception and didn’t print it:
exc.printStackTrace()

The actual problem probably has to do with the OS not finding the JOGL libraries. Put the DLLs in the same directory as your JAR, and see how that works out.

I had considered that, actually. I tried making it print something. I ran it from the command line… It printed nothing ಠ_ಠ. Also the DLLs are indeed in the same directory as the jar. This makes no sense.

If you have a static block in your class, they will be executed before the main() method.

Why don’t you go back to basics and try to make a Hello World program work. No libs, no jars, just a *.class.

Once that works, put the class in the jar, and run it like:
java -cp hello.jar HelloWorld

Then add the manifest, with the Main-Class entry, and run:
java -jar hello.jar

Work from there.

When you find a bug always simplify, fix it, try again. You’ll never get anything done when you only determine that “super fancy code” doesn’t work, and trying to fix it by trial and error.

Thanks for the advice. I tried and it doesn’t work. There must be something wonky somewhere along the line. I’ma be right back- gonna DFE and start things from scratch.

EDIT - Okay I deleted all my Java installs, including Netbeans. I installed everything fresh, including a newer version of Netbeans. I loaded my project back in and got it working again in Netbeans. Built it- and NOTHING. Even better, I fired up one of the sample projects that uses JOGL, built that, and it worked. I’m at a loss.

Does your manifest have a line like:


Class-Path: lib/jogl.jar lib/gluegen-rt.jar

take that sample project and put System.out.println(“HelloWorld”) on the first line in main(String[])
it should be written to the console

take that your own project and put System.out.println(“HelloWorld”) on the first line in main(String[])
is it written to the console?

Indeed it does, Zoto. What really gets me is that one of the default JOGL demos works perfectly fine. I’ve checked that project’s settings and libraries and manifest file and everything and it’s all exactly the same. I’m thinking maybe the problem has to do with my code. I’m going to change my code to look like the basic structure of the demo (which differs a bit from my code). Unfortunately that will mostly have to wait until after work. I can’t think of a more infuriating way to spend my day than working when I have something like this on my mind, heh.

As said in my first reply, it’s fairly likely that you caught and ignored an exception.

That, or you have buggy gfx drivers and you setup your context a bit different.

It seriously doesn’t print anything either way. What the hell is wrong with my computer…

Give ALL the code of your HelloWorld app.

Sorry that’s going to have to wait. I need to go get ready for work tonight, like right now. When I get back I’m going to try my last ditch effort to fix the problem. Then I’ll try putting up code.

Okay I’m playing around with the sample demo that uses JOGL, and came with Netbeans. It works perfectly fine when built, so I think it has something to do with how the OpenGL is brought into the program. I’ll play around with it.

Maybe you found the problem in the meantime, but it sounds like your library path is incorrect so it can’t find the required .dll/.so files.

Like what I said in my first reply :slight_smile:

ah yes, indeed :slight_smile: