Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-29-2007, 10:23 AM
Member
 
Join Date: Nov 2007
Posts: 5
Rep Power: 0
j0h@nb is on a distinguished road
Question Main startup class
I have a Flash application from which i call a few java executables that are supposed to open other programs/files etc. Works well from where i'm sitting, but one of my clients is having trouble with it. Whenever he clicks on a button that calls one of the java programs he receives an error that states: "The main startup class could not be found".

Any ideas what could cause this?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-29-2007, 10:32 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,473
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Main class(actually class which has main method) may be missing. Check whether it is there first.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-29-2007, 12:23 PM
Member
 
Join Date: Nov 2007
Posts: 5
Rep Power: 0
j0h@nb is on a distinguished road
Default
Yup, here's the code i'm using...

Code:
import java.util.*;
import java.io.*;

public class OpenFile
{
	public static void main(String args[])
	{
		
		try{
			String userdir = System.getProperty("user.dir");
			
			String parsedUserdir = userdir.substring(userdir.indexOf(":")-1,userdir.indexOf(":")).toLowerCase();
			
			String fileName;
			
			if(parsedUserdir.equals("c")){
				fileName = "C:\\temp\\fscommand\\4400796_Diagnosfil_PropPlus_SE.P1D";
			}else if(parsedUserdir.equals("d")){
				fileName = "D:\\fscommand\\4400796_Diagnosfil_PropPlus_SE.P1D";
			}else if(parsedUserdir.equals("e")){
				fileName = "E:\\fscommand\\4400796_Diagnosfil_PropPlus_SE.P1D";
			}else if(parsedUserdir.equals("f")){
				fileName = "F:\\fscommand\\4400796_Diagnosfil_PropPlus_SE.P1D";
			}else{
				fileName = "G:\\fscommand\\4400796_Diagnosfil_PropPlus_SE.P1D";
			}
			
			Runtime rt = Runtime.getRuntime();

			Process proc1 = rt.exec( "cmd /C start "+ fileName );
			proc1.waitFor();

		}catch(Throwable t){
			t.printStackTrace();
		}
	}
}
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-29-2007, 12:43 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,473
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
This code is ok. If the correct file in correct drive/path it opens. So what is your issue here.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-29-2007, 12:56 PM
Member
 
Join Date: Nov 2007
Posts: 5
Rep Power: 0
j0h@nb is on a distinguished road
Default
Well, one of my clients gets an error when running this. Works well on my machine, but as he runs it on his machine it says "The main startup class could not be found". Could it have something to do with his configuration? (security or whatever...?)
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-29-2007, 01:05 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,473
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
I don't think so. This application not deal with such security level. Is that your complete application run on an applet. If so the browser can't be support it. Specially in FF.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-29-2007, 01:11 PM
Member
 
Join Date: Nov 2007
Posts: 5
Rep Power: 0
j0h@nb is on a distinguished road
Default
Forgot to mention...it's a standalone flash app, so it doesn't run from a browser. Runs from a CD or usb-drive.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 11-29-2007, 01:15 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,473
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Hmm, according to your error message, it wont be related with the wrong file path of the searching file. More possibility to missing the main class, the above class.

You say that the application you have with is working. Can you test your working application on your clients' machine.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 11-29-2007, 05:05 PM
Member
 
Join Date: Nov 2007
Posts: 5
Rep Power: 0
j0h@nb is on a distinguished road
Default
Turned out that they didn't allow JVM on their machines. Problem partially solved, now i just need another workaround. Thanks for the efforts. :-)
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 11-30-2007, 04:47 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,473
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by j0h@nb View Post
Turned out that they didn't allow JVM on their machines.

This is interesting. How did you find that JVM not allowed this.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 11-30-2007, 05:44 AM
Member
 
Join Date: Nov 2007
Posts: 18
Rep Power: 0
sandeepkk2005 is on a distinguished road
Default
Have you put it in the executable jar file?
If yes in manifest file you have to specify Main-Class name with full package name.
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 11-30-2007, 05:50 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,473
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Great, yes it can be a reason. But if he use the same type of package on his message, it wont be happened.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 11-30-2007, 06:35 AM
Member
 
Join Date: Nov 2007
Posts: 18
Rep Power: 0
sandeepkk2005 is on a distinguished road
Default
Package is not a problem in this case.
It seems to problem with not specifying Main-Class attribute in Jar File.
There is no other way this can happen.
Program is correct.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 11-30-2007, 06:44 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,473
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Originally Posted by sandeepkk2005 View Post
Package is not a problem in this case.
Sorry you don't get me. What I've mean by package is the whole project. Sorry for the confusing.

Originally Posted by sandeepkk2005 View Post
It seems to problem with not specifying Main-Class attribute in Jar File.There is no other way this can happen.
Program is correct.
Yes the program is correct. Actually this is not the only issue on this. j0h@nb says that there is some issue with JVM.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not find the main class, program will exit. aryubi New To Java 39 02-19-2010 11:02 AM
Startup time JavaForums Java Blogs 0 02-04-2008 12:40 PM
Calling a variable from main to another class itsme New To Java 1 12-18-2007 04:35 PM
how to load a java class in startup leonard Advanced Java 1 08-06-2007 04:36 AM
Error: Could Not Find Main Class. Program Will Exit silvia New To Java 1 07-19-2007 05:58 PM


All times are GMT +2. The time now is 11:44 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org