permaculture playing cards
The moose likes Applets and the fly likes Problem running a .jar file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Problem running a .jar file" Watch "Problem running a .jar file" New topic
Author

Problem running a .jar file

karl neumann
Greenhorn

Joined: Sep 03, 2012
Posts: 5
Hello java ranchers. I developed a java applet in eclipse for the first time which I plan on uploading to my website. The applet runs great within eclipse. However, when I export this project to a jar file and try to run the jar file from a command prompt I get: "no main manifest attribute, in myClass.jar" . After searching many sites for an answer I added the following line to my MANIFEST.MF file: Main-Class: org.eclipse.jdt.myClass .When I run the jar file again I get the same message as before. I am not sure if org.eclipse.jdt is correct. I got this from the .classpath file and it's a guess. When I run the jar file again I get the same message as before. Other observations: the myClass.java source file has no main() or int() method. I don't know if that's relevant or not. I am at my wits end trying to figure this out. Please help!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 5040
    
  10

Hello karl and welcome to the Ranch! You need to go through the tutorial trail on Developing and Deploying Java Applets.

Briefly, Applets can't be run with the java -jar command. They normally run in a browser, and can be run in the applet viewer, usually from an IDE.


luck, db
There are no new questions, but there may be new answers.
karl neumann
Greenhorn

Joined: Sep 03, 2012
Posts: 5
Thanks for the advice. I have read the tutorial and I am making progress. I have rewritten much of the source code in eclipse. Once again, the applet runs in eclipse. After having exported the project to a jar file, and creating some html code, I am now running the applet from a .htm file. When running the applet I am getting an AccessControlException: access denied("java.io.FilePermission""myPic.jpg""read"). The .jpg file is included in the jar file.
What now?
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19739
    
  10

I'm guessing that your applet tries to read files from the client's system. Applets aren't allowed to do that -- for security reasons -- unless they are signed.

But let me ask: is there a particular reason you are writing an applet, rather than an ordinary Java application? If you're a beginner then it would be better to write an application.
karl neumann
Greenhorn

Joined: Sep 03, 2012
Posts: 5
The applet is for my website. Thanks for the sales pitch.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19739
    
  10

Okay. Then why is your applet trying to read files from the client machine?
karl neumann
Greenhorn

Joined: Sep 03, 2012
Posts: 5
Here is my applet: besteartraining.com
spare me the advice please.
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19739
    
  10

Okay. Then do you still have a question? If so, then what is it?
Paul Clapham
Sheriff

Joined: Oct 14, 2005
Posts: 19739
    
  10

Also, as a moderator I'm required to give you advice about certain topics. So I would just like to remind you that this forum has a rule, and that rule is "Be Nice".
karl neumann
Greenhorn

Joined: Sep 03, 2012
Posts: 5
If your advice to beginners is to refer them to the java api, then don't bother. We can find it on own. If you are the moderator, I don't need your worthless forum. You know what you can do with yourself!
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1051
    
    5

All the best Karl
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem running a .jar file
 
It's not a secret anymore!