Main Class not found.

  • (2 Pages)
  • +
  • 1
  • 2

25 Replies - 19159 Views - Last Post: 17 April 2009 - 11:18 AM Rate Topic: -----

#1 stauffski  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 210
  • Joined: 03-November 07

Main Class not found.

Post icon  Posted 26 March 2009 - 12:29 PM

Java works great on my Vista machine... well, it did. Recently I installed the new JRE update with FX I think and ever since, no .jar file has worked. I have uninstalled all java components and reinstalled older versions and the current version, nothing has worked. Currently my JDK is operating properly, but the JRE is not. .jar programs that used to work, don't anymore.

Originally the I would try to run a .jar file and it the machine would tell me it did not know of any program it could run with. So I remmapped the .jar extension to the javaw.exe in the 6_13 JRE bin and now it returns an error: "Could not find the main class. This program will now exit."

Right now I have JDK 6_13 and JRE 6_13. I have tried many things but I'm not going to mention them so as not to bias anyone's thoughts. Any suggestions?

Thanks,
Stauffski

Is This A Good Question/Topic? 0
  • +

Replies To: Main Class not found.

#2 thebpf  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 42
  • Joined: 19-March 09

Re: Main Class not found.

Posted 26 March 2009 - 12:45 PM

I'm assuming that the .jar file opened fine with your previous installation of Java Runtime? Because that error, to me anyway, means that the application class in the .jar file couldn't be located (ie couldn't find a main method). If you open the .jar with WinZip you can look at the manifest file, and that should tell you what class it's trying to run.

It should say something like:

Manifest-Version: 1.0
Main-Class: Magnifier
Classpath: .Magnifier.jar


View Poststauffski, on 26 Mar, 2009 - 11:29 AM, said:

Java works great on my Vista machine... well, it did. Recently I installed the new JRE update with FX I think and ever since, no .jar file has worked. I have uninstalled all java components and reinstalled older versions and the current version, nothing has worked. Currently my JDK is operating properly, but the JRE is not. .jar programs that used to work, don't anymore.

Originally the I would try to run a .jar file and it the machine would tell me it did not know of any program it could run with. So I remmapped the .jar extension to the javaw.exe in the 6_13 JRE bin and now it returns an error: "Could not find the main class. This program will now exit."

Right now I have JDK 6_13 and JRE 6_13. I have tried many things but I'm not going to mention them so as not to bias anyone's thoughts. Any suggestions?

Thanks,
Stauffski

This post has been edited by thebpf: 26 March 2009 - 12:56 PM

Was This Post Helpful? 0
  • +
  • -

#3 stauffski  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 210
  • Joined: 03-November 07

Re: Main Class not found.

Posted 26 March 2009 - 01:01 PM

It said:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 10.0-b23 (Sun Microsystems Inc.)
Main-Class: savestopper3.Main
Class-Path:
X-COMMENT: Main-Class will be added automatically by build


However this should not matter because this program has remained untouched and has worked before on this machine and others. NO .jar file works. Not even one I compiled 30 seconds ago.
Was This Post Helpful? 0
  • +
  • -

#4 thebpf  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 42
  • Joined: 19-March 09

Re: Main Class not found.

Posted 26 March 2009 - 02:24 PM

This is going to sound like a stupid question because I'm sure you've already done this. But have you checked the Application Runtime Settings in the Java Control Panel? Remapped .jar files to open with a previous JRE. Again, I'm just shotgunning ideas, sorry if you've already tried these.

View Poststauffski, on 26 Mar, 2009 - 12:01 PM, said:

It said:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 10.0-b23 (Sun Microsystems Inc.)
Main-Class: savestopper3.Main
Class-Path:
X-COMMENT: Main-Class will be added automatically by build


However this should not matter because this program has remained untouched and has worked before on this machine and others. NO .jar file works. Not even one I compiled 30 seconds ago.

Was This Post Helpful? 0
  • +
  • -

#5 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Main Class not found.

Posted 26 March 2009 - 04:20 PM

Welcome to the wonderfull world of Vista :D

May be not related but....
My good old laptop XP is about to dies after 5 years of loyal services
On that laptop I had:

C:\Eclipse that contained my Eclipse expanded .zip
C:\PblJava where under different subdirectories are all my Eclipse workspaces

Bought a new Vista laptop... OK logically copying these 2 directories to the new Vista laptop everything should work ?
Right ? Just a little change on Eclipse path on Vista it is C:\Program Files (x86) instead of \Program Files

OK copied both directories.

Started Eclipse... seems to work.
Load a workspace... error everywhere
Elclipse recognized all Java keywords but no class recognizion... neither String or any class because Object not defined
Delete *.class
Same problem

OK may be my XP Eclipse does stupid things on Vista ?

Delete c:\Eclipse
Install the newest Eclipse release... same problem

Rename \PblJava \OldPblJave
Create directory \PblJava

Re-start Eclipse
Create new Workspace in \PblJava with the same name as an older one
From Eclipse import file system *.java from \OldPblJava
worked like a charm :D

What happened ? Not a slightest clue/idea
All that to say that I am not surprised of what is happening to you
Better to start from scratch

? ? ?

By the way.. I have a hard time with my mouse on my Vista laptop.. always send me a little <-> icon like if I had a wheel and wanted to use it. Do you know how to get rid of that crap ?

This post has been edited by pbl: 26 March 2009 - 04:40 PM

Was This Post Helpful? 0
  • +
  • -

#6 BigAnt  Icon User is offline

  • May Your Swords Stay Sharp
  • member icon

Reputation: 101
  • View blog
  • Posts: 2,392
  • Joined: 16-August 08

Re: Main Class not found.

Posted 26 March 2009 - 04:46 PM

Quote

Re-start Eclipse
Create new Workspace in \PblJava with the same name as an older one
From Eclipse import file system *.java from \OldPblJava
worked like a charm biggrin.gif

What happened ? Not a slightest clue/idea
All that to say that I am not surprised of what is happening to you
Better to start from scratch


Think this was a bug based on default locations such as:

Quote

The default workspace folders for Vista and XP are different this way (Documents vs. My Documents), so that's the root of the problem.


From a feedback on Eclipse I saw a while back, don't know the status of the bug report and can't seem to find it anymore.

Another reason why I'm glad that the school images still use XP instead of Vista because of issues just like this.

And why I have Fedora imaged onto my desktop in place of Windows.
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Main Class not found.

Posted 26 March 2009 - 05:22 PM

View PostBigAnt, on 26 Mar, 2009 - 03:46 PM, said:

The default workspace folders for Vista and XP are different this way (Documents vs. My Documents), so that's the root of the problem.

I was using the browser for existing Workspace... so it found them and opend the files
but was unabled to compile them...

May be the workspace specifies which JRE to use and these were pointing to \Program Files but I changed that in Windows preference" without success
Was This Post Helpful? 0
  • +
  • -

#8 BigAnt  Icon User is offline

  • May Your Swords Stay Sharp
  • member icon

Reputation: 101
  • View blog
  • Posts: 2,392
  • Joined: 16-August 08

Re: Main Class not found.

Posted 26 March 2009 - 05:32 PM

I know Eclipse keeps the configuration log such as :

Quote

!SESSION 2009-03-13 10:56:34.561 -----------------------------------------------
eclipse.buildId=I20070625-1500
java.version=1.6.0_11
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Command-line arguments: -os win32 -ws win32 -arch x86 -data D:\My Documents\homework\Spring09\SE2811\2811Eclipse


But I thought this is updated each time the workspace was closed/opened. But maybe it isn't? Since the last edit seems to be the 13th but I Have used it alot since then.

This post has been edited by BigAnt: 26 March 2009 - 05:32 PM

Was This Post Helpful? 0
  • +
  • -

#9 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8325
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Main Class not found.

Posted 26 March 2009 - 05:36 PM

Good, but that does not fix Stauffski problem :angry:
Too bad, I usually like the problem this guy post
Was This Post Helpful? 0
  • +
  • -

#10 BigAnt  Icon User is offline

  • May Your Swords Stay Sharp
  • member icon

Reputation: 101
  • View blog
  • Posts: 2,392
  • Joined: 16-August 08

Re: Main Class not found.

Posted 26 March 2009 - 06:00 PM

Getting back on topic. Do you have sufficient privilege to run the jar files? UAC is the source of many problems in Vista.
Was This Post Helpful? 0
  • +
  • -

#11 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,028
  • Joined: 11-December 07

Re: Main Class not found.

Posted 27 March 2009 - 02:02 AM

What does the system classpath look like? Does it include .?

Another thought. You are using javaw -jar yourapp.jar, right?

This post has been edited by cfoley: 27 March 2009 - 02:05 AM

Was This Post Helpful? 0
  • +
  • -

#12 stauffski  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 210
  • Joined: 03-November 07

Re: Main Class not found.

Posted 29 March 2009 - 09:33 PM

Basically I think I have narrowed my problem down... When I run the any jar file from Windows CMD, everything works fine. So I think the .jar file path is linked to the wrong program. So what exactly does it need to open with?
Was This Post Helpful? 0
  • +
  • -

#13 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1940
  • View blog
  • Posts: 4,028
  • Joined: 11-December 07

Re: Main Class not found.

Posted 30 March 2009 - 03:04 AM

It needs to open with javaw using -jar. It could be a classpath issue. Did you check that out? If . (i.e. the current directory) isn't in your classpath it won't know where to look for the main class.
Was This Post Helpful? 0
  • +
  • -

#14 stauffski  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 210
  • Joined: 03-November 07

Re: Main Class not found.

Posted 30 March 2009 - 07:53 AM

That sounds like we're headed the right dirrection, but how should I set that up? With the regular Windows open with dialog, you can't also specify an argument to be sent with as well. Correct? So I'm going to attempt to do it in the registry. If anyone knows exactly where to look in the registry, please, do tell.
Was This Post Helpful? 0
  • +
  • -

#15 stauffski  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 210
  • Joined: 03-November 07

Re: Main Class not found.

Posted 30 March 2009 - 11:32 AM

An update: I located the location in the registry that controls what opens when you click an extension, but now I need help tinkering with it.

There is one String value that links the .jar file to the javaw.exe file. It reads:(Default) | REG_SZ | "C:\Program Files\Java\jre6\bin\javaw.exe" "%1". I believe the last piece of data in quotes contains the arguments for the program, but I have tried numerous things and none are quiet working. I'm getting close, but I need to know what to put in as an argument.

Note, for just about everything that I use in place of "%1" I get an error dialog that says "Could not find the main class: (the text that I entered). Program will exit.

Idea: Could anyone check their registry and tell me what theirs says? I found the reg value at the path: HKEY_USERS\S-1-5-21-2116791129-961088311-2111660836-1000_Classes\jar_auto_file\shell\open\command

Thanks,
Stauffski
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2