It's not a secret anymore!
The moose likes Beginning Java and the fly likes Java Virtual Machine troubleshooting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java Virtual Machine troubleshooting " Watch "Java Virtual Machine troubleshooting " New topic

Java Virtual Machine troubleshooting

Fernando Mendez

Joined: Jun 06, 2004
Posts: 10
Excuse my english
I have the following problem:

I have a proyect created, when a try to open the .jar file (created for the accion of build of my IDE (Using NetBean)), I get this message from JAVA VIRTUAL MACHINE LUNCHER : "could not find the main class, program will exit", but the proyect it does have the main class of the proyect set, the thing that confuse me , is that Apparently the error is cause by a line of code that is in a Action performed event of a button, the line belong to the jasper report, and is the one that is use for loading the xml design file: "JasperDisign jasperdisigh = JRXmlLoader.load("C:/Reporte1.jrxml");", but how can this generate error if the events has not been fire, the only thing that come to my mind is, that there is some file o library that I have to put in some place,

When I take out the line that load the xml everything run just fine.

Note: this not happen in the IDE , in here I have no error , no exception , the form that is as main has not deprecated Api, and every run just fine.

I don�t know what to do, I going crazy , I have like 2 weeks with this error.

[ March 03, 2005: Message edited by: fernando mendez ]
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
You could improve your chance of getting help by easing up, keeping it down and using a meaningful subject line. You can edit your post by using the edit icon at the upper right of your post.

Good speed!

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

When you launch an executable JAR, the classpath is "closed", and only classes inside the JAR will be loaded (along with any standard extensions and platform libraries from the JRE, of course.) In the IDE, the classes JasperDisign and JRXmlLoader are available, but when you create a JAR file, perhaps they're not. This will cause the class containing this line to fail to load, hence the "could not find main class" error.

So I think what you need to do is make sure that all the classes needed for your application are available in the JAR file. Remember that CLASSPATH isn't used when running an executable JAR.

[Jess in Action][AskingGoodQuestions]
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
You state that this error doesn't happen when you run your program in the IDE. So how DO you run it? Is it from the command line or some other method? If you are using the command line, please post the exact command you use along with the exact output you get. This will help use more clearly understand what your problem is, and hopefully we can come up with more specific solutions for you to try.


Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: Java Virtual Machine troubleshooting
It's not a secret anymore!