Results 21 to 40 of 42
- 03-03-2012, 02:59 PM #21
Member
- Join Date
- Mar 2012
- Posts
- 22
- Rep Power
- 0
Re: Java Could not find main class...
Hope this image kind of shows every step I made, and the error message, my code for the program is: which works fine in the eclipse output (viewer)
Java Code:import javax.swing.*; public class HelloWorld { public static void main (String[] args) { String helloWorld = " Hello World!! "; JOptionPane.showMessageDialog(null, helloWorld); } }
Uploaded with ImageShack.us
- 03-03-2012, 03:11 PM #22
Re: Java Could not find main class...
That wasn't what I was looking for.
Open the directory with the jar file
Double click on the jar file
Print screen the error message
How did you double click on the jar file when you took the screen print?
How many versions of the jar file and program are there?
The one you posted in post#1 is in a package: test.
The one you just posted shows Main-Class: HelloWorld not in a package.
Delete all versions of the jar file and create a new one for testing.Last edited by Norm; 03-03-2012 at 03:14 PM.
- 03-03-2012, 03:31 PM #23
Member
- Join Date
- Mar 2012
- Posts
- 22
- Rep Power
- 0
Re: Java Could not find main class...
Sorry I let me do that again in post =1
Its the same error message, what ever java program I export into a jar file it does the same message.
Screenshot: (Started from beginning)

Uploaded with ImageShack.us
Regards
- 03-03-2012, 03:33 PM #24
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: Java Could not find main class...
Isn't your class in a package 'test'? Your JVM seems to be looking for a class in the default (no name) package; check the manifest entry.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-03-2012, 03:35 PM #25
Re: Java Could not find main class...
The most likely error is multiple versions of a file.
How many versions of the jar file and program are there?
The one you posted in post#1 is in a package: test.
The one you just posted shows Main-Class: HelloWorld not in a package.
Delete all versions of the jar file and create a new one for testing.
- 03-03-2012, 03:46 PM #26
Member
- Join Date
- Mar 2012
- Posts
- 22
- Rep Power
- 0
Re: Java Could not find main class...
Ok, I deleted all version of my jar and created a new work space and new files I have created a new HelloWorld file etc.
I have the same error..
Here is my extracted java file manifest:
There is no package with this new file. just the default packageManifest-Version: 1.0
Class-Path: .
Main-Class: HelloWorld
- 03-03-2012, 05:05 PM #27
Re: Java Could not find main class...
If there are no packages anywhere then that should work.
Did you do a Search for the jar files and delete ALL of them and then create a new jar file with a manifest and a class file that don't use packages?
- 03-03-2012, 05:59 PM #28
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: Java Could not find main class...
Does the last line of your manifest file have an end-of-line character? (e.g. \r\n on an MS Windows machine or \n on a Unix/Linux machine).
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 03-03-2012, 06:25 PM #29
Member
- Join Date
- Mar 2012
- Posts
- 22
- Rep Power
- 0
Re: Java Could not find main class...
Yes and No its just blank
I just don't know why it doesn't work. If you guys wouldn't mind could i upload the .jar file? so you could take a look at the complete file?
You could see that the manifest file is all correctly listed and if it is a problem my end, or the file..
File name: HelloWorld.jar File size: 683 Bytes
Thanks in advance
- 03-03-2012, 06:33 PM #30
Re: Java Could not find main class...
It works for me:
C:\Temp>D:\Java\jre7\bin\java.exe -jar HelloWorld.jar
Hello World!
- 03-03-2012, 06:47 PM #31
Member
- Join Date
- Mar 2012
- Posts
- 22
- Rep Power
- 0
Re: Java Could not find main class...
ok, does it work when you double click it?
It works for me through the CMD, but not when i double click it. why would that be?
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Administrator>java -jar HelloWorld.jar
Hello world
C:\Users\Administrator>Last edited by DiciWales; 03-03-2012 at 06:50 PM.
- 03-03-2012, 07:03 PM #32
Re: Java Could not find main class...
Why are the outputs from the programs different? You still have more than one version of the jar file!!!
What do you expect to happen when you double click on the program? There is no console to see its output.
- 03-03-2012, 07:15 PM #33
Member
- Join Date
- Mar 2012
- Posts
- 22
- Rep Power
- 0
Re: Java Could not find main class...
Ok so, in order for a java file to be clickable and run on its own without the CMD.. it needs to have more in it?
could you perhaps give me an example of the minimum or what not code for a java application? so it just displays something simple as "Hello World!"
Or point me to what I need to have a small box appear when i double click the file which "Hello World!" is displayed?
Much appreciative of your help so far! I can't thank you enough
(sorry for seeming really stupid, but I'm very new to java)
- 03-03-2012, 07:36 PM #34
Re: Java Could not find main class...
Your program is executing but you don't see it. If the code wrote a file to disk you could see from the date on the file when it was last written to and know that the program executed.in order for a java file to be clickable and run on its own
Look at using the JOPtionPane class. It can display a small box with a message. Lots of sample code here on the forum if you do a Search.I need to have a small box appear
- 03-03-2012, 07:46 PM #35
Member
- Join Date
- Mar 2012
- Posts
- 22
- Rep Power
- 0
- 03-03-2012, 07:49 PM #36
Re: Java Could not find main class...
We all were beginners.
- 03-04-2012, 02:40 PM #37
Re: Java Could not find main class...
hi
i have a similar problem.. I just want to access a data from another class through inheritance, and don't know, where to declare the accessed variable
lol .. I'm pasting my program codes..
import java.io.*;
import java.util.*;
public class inheritance extends bb{
public static void main() {
int a=1;
System.out.println("a is "+a+"b is"+b);
}
class bb {
int b=2;
}
}
- 03-04-2012, 02:43 PM #38
Re: Java Could not find main class...
Please start a new thread with your problem.
- 03-04-2012, 02:44 PM #39
Re: Java Could not find main class...
oh.. i dint know how to start, im checking it right now, and thx for the king reply
- 03-04-2012, 02:49 PM #40
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: Java Could not find main class...
When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Could not find or load main class: c:\java\HelloWorldApp
By Atticus in forum New To JavaReplies: 10Last Post: 02-02-2012, 08:26 PM -
Could not find the main class: java. Program will exit
By thewonkits in forum New To JavaReplies: 3Last Post: 01-11-2012, 11:56 AM -
newbie question: Error: Could not find or load main class Java Result: 1
By ideaman in forum New To JavaReplies: 7Last Post: 01-01-2012, 12:29 PM -
Error: Could not find or load main class Ops.java
By Javasubbu in forum New To JavaReplies: 4Last Post: 10-05-2011, 10:52 PM -
Java virtual machine:Could not find Main Class: d. Program will exit.
By xHolyMariox in forum New To JavaReplies: 4Last Post: 08-22-2011, 03:42 PM


1Likes
LinkBack URL
About LinkBacks


Bookmarks