theme studio for jscookmenu - java

I'm trying to run theme studio for jscookmenu, by double-clicking the file js-cook-menu_2.30.jar. But when I do that, I get the following message:
"Failed to load Main-Class manifest attribute from C:\dev\tapestry-jsmenu_2.30\js-cook-menu_2.30.jar"
After searching on the internet, I found that it is necessary to specify a main class in the file manifest.mf of a jar file in order to run it. I thought that if I modified js-cook-menu_2.30.jar and I add a manifest.mf specifying a class with a main method, I could run the program.
I looked on the source code provided with the downloadable package, but no success.
Could someone help me with this?

Your error is exactly what it says it is. A main class and a main method of another class are very different things. Per your error message, the documentation and what you found from looking you need to add a main class, so that's what I would recommend doing.

Related

Q: No main manifest attribute, and Could not find or load main class. How do I structure the Main Manifest attribute for Gradle?

I have been trying to compile my jar file into an executable jar file. I learned that I need to set the Main Manifest from my first error. My problem is that whatever I try to put in as the fully qualified name for the Main class, It still tells me that the class isn't found.
Things I've tried
Not using a package and just putting Main as the Main-Manifest
Using a package and putting (packagename).Main
(packagename).Main.class
Pressing Ctrl+Shift+Alt+C which supposedly copies the fully qualified name and putting that in
I've tried looking at tons of previous questions and couldn't find anything, I've probably spent like 10 hours on this and would appreciate it if someone could help me. I think that I am somehow incorrectly structuring what I'm supposed to put in.
Thank you in advance!
For anyone having future problems, try and use shadow to build your project, fixed my problem even though the error didn't say it was missing dependencies.

Java - Could not find or load main class gui

I understand that there are many similar questions and answers, but none of the answers fit what I am trying to do. I have a file called gui.java and I am trying to turn it into a jar file, LifeGame.jar I keep the .java and the .class in a folder, and when I try to archive it, it works, but when I try to run the file, it gives me Could not find or load main class gui. I do give a manifest called "META-INF:MANIFEST.MF" and the folder is stored on my desktop.The manifest looks like:
Main-Class: gui
I would like some advice on what to do and how to fix this problem. (As I have already said, I understand this is a clone of many other questions, but the examples I've seen don't work for me in my situation)
EDIT:
Some details on my scenario:
I have multiple classes in gui.java but only one of them is public, the rest aren't private of public. It is on my desktop and when I try java gui it gives the same error as when I try archiving it into a Jar.
Name of your main class should be gui. check your .class file which is created to be gui.class or any other. It doesn't matter the name of .java file but the name of .class file.

JavaFX: Need help understanding project hierarchy issues

My code has gotten quite large and so I've decided to build a runnable JAR to see how it's done. I probably should've tried sooner because I'm getting 2 different errors related to the project structure, first is the "no main manifest attribute error" when trying to run the JAR from command prompt. Double-clicking the JAR does nothing (Win7). The second issue is related to the FXMLLoader explained lower down.
I followed the steps here to build the JAR, which involved moving all Maven files into the JAR directory. The compiled JAR gave me the manifest error, so I followed this which adds a Maven plugin in my pom.xml file. The error might be caused by a wrong naming convention with the line <mainClass>com.primary.Drag</mainClass> where primary is the package and Drag is my Drag.java file (class) which has the main method.
Inititally I was using the default package but read that this is not recommended for larger projects, so I put all my files into "primary". Here is my current hierarchy as shown in IntelliJ:
The problem is that ever since I created the "primary" package, I can no longer even compile the program via IntelliJ, let alone build a runnable JAR. This is due by the second error I mentioned, which is java.lang.IllegalStateException: Location is not set. on this line within primary/Drag.java:
FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("firstlaunch.fxml")); It used to work with the default package, but not anymore.
I tried replacing firstlaunch.fxml with /primary/firstlaunch.fxml and /resources/firstlaunch.fxml (with and without moving resources into primary package) but no luck.
3 Related Questions:
Is my project structure incorrect?
How do I reference the fxml file from the primary package?
Is this what I should write in Maven's mainClass tags? <mainClass>com.primary.Drag</mainClass>
Is my project structure incorrect?
Answer:
Your package name should be like com.primary.******
How do I reference the fxml file from theprimary package?
Answer:
Always make sure that you are trying to load firstlaunch .xml from the class which is located in same package where that xml is kept. Means class which you wrote the loading code and xml file should be in same package
Is this what I should write in Maven's mainClass tags?com.primary.Drag
Answer:
If you package name corrected to com.primary , your main class Drag will correctly added by maven

Finding the Main Class

I have my first application written in Netbeans, with supporting libraries. After building the project, the file NetbeansProjects/PDF/dist/PDF.jar runs fine.
I'm ultimately trying to build a OSX app, but think(?) that the first step is to bundle the PDF.jar and the /lib/*.jar files together.
To this end, I'm using JarSplice, but can't work out how set the Main Class. I think it should be found in the manifest.mf file, but it doesn't seem to contain anything. JarSplice requests:
Enter your applications main class file below, complete with any packages that it maybe in.
E.g: my package.someotherpackage.MainClass
Adding System.out.println(main.getClassName()); to my main method gives me "PDF" in the output window of Netbeans.
Can someone tell me how I go about finding the main class, and ideally, because I'm an idiot, exactly what to input into as the main class into JarSplice?
It depends were you put your main class when developing.
Try the class name that contains your main method, if you put your main method in Test.java then put;Test
If your main class is nested in a package then put something like org.package.Test
Once you export your .jar open up the Manifest file and next to Main-Class: should have the main class, just copy and paste

Confusion on Uses of Jar Manifest File

I am reading packaging java applications with jar tool. I noticed a manifest file is created under META-INF directory. For a simple application, it felt like, it's serves no purpose. I searched on stackoverflow to understand the usages of Manifest file. I came across UsesOfManifestFile. While reading the answer, i got confused on point 2 and 3 which are :-
What are download extensions? I am not able to understand the concept in the answer.
What does it mean to seal the jar? It has given an example below like this
Name: myCompany/MyPackage/ Sealed: true
What is the use of putting such information? Can someone elaborate on these points.
Thanks.
The manifest file is like the guidance instructions for the java program to run the jar. When the manifest is created it will hold crucial information, for example a reference to the main program. When the java program runs your jar it doesn't know where to start, so it look sin the manifest for a line telling it where the class with the main method is so it has a start point for the program. Another use is a classpath line, which will tell the program where to find any 3rd party library's in the jar are, otherwise again, the java program won't find them.
There is a range of data that can be stored in the manifest file, I would recommend checking out the Oracle information on them and seeing if that clears it up a bit more.
EDIT: From the Oracle site regarding your example:
Packages within JAR files can be optionally sealed, which means that all classes defined in that package must be archived in the same JAR file. You might want to seal a package, for example, to ensure version consistency among the classes in your software.
You seal a package in a JAR file by adding the Sealed header in the manifest, which has the general form:
Name: myCompany/myPackage/
Sealed: true
The value myCompany/myPackage/ is the name of the package to seal.
Note that the package name must end with a "/".
What this appears to mean is that any and all classes that you use in your program must be within the same jar file.
EDIT 2 (For comment response)
A manifest may contain the following line:
Main-Class: com.mkyong.awt.AwtExample
When the javaw.exe (I think) runs your runnable jar, it has no idea where to start from, all java programs run via a main method, but if you have say 50 class files in your jar, it has no idea which one has the main method to start from. It will look at the manifest file, reads your above line and thinks right, the main method is in the package com.mkyong.awt and the class is AwtExample, it then finds this class and runs the program from that main method. It's most basic function within the jar is to tell the java program running the jar where to find the stuff it needs to run your jar.
Note: that example manifest entry came from a little tutorial which shows how to create a simple runnable jar.
Good Luck!

Categories

Resources