Eclipse Error: Could not find or load main class opencv - java

I keep getting these error every time I try to run the jar file I follow most of the questions that have been asked here haven't worked :(
and every time I export the jar file I got these warning
enter image description here
and this is my MANIFEST.MF
Manifest-Version: 1.0
Class-Path: .
Main-Class: gui_rec.Main
any suggestions?

Try to specify in your MANIFEST.MF classes to include in the Class-Path header field in the manifest file of an applet or application. The Class-Path header takes the following form:
Class-Path: jar1-name jar2-name directory-name/jar3-name
For more info go to link

Related

fail to execute jar file in linux

I had developed a standalone program which don't have any GUI, it's only use in the linux machine(without any GUI). So, i converted my java source code into jar file using the following command
jar cfm hardcoded.jar manifest.txt hardcoded.class
The jar file was successfully created but when i try to execute the jar file in the terminal,i get this error
no main manifest attribute, in hardcoded.jar
Some of the information said that the problem due to the manifest file but i can't figure out where is the root cause because i am very new to java on linux,Some people said that the package also need to include but where can i find my package name?.My manifest file is showed as the following
Manifest-Version: 1.0
Class-Path: ./ commons-logging-1.1.2.jar httpclient-4.5.2.jar htt
pcore-4.4.1.jar java-json.jar java-rt-jar-stubs-1.5.0.jar javax-ssl-1
_1.jar joda-time-2.2.jar
Class-Path: .
Main-Class: hardcoded
As you can see my manifest file, i had some others external library, i know eclipse have the build in function to solve this issue, how i need to solve it in linux environment ?

Creating Executable jar from CMD prompt

I have following class files,jar and manifest in a directory
Dot.class
Bridge.class
jsch.jar
MANIFEST.MD
Manifest file contains following two lines
Manifest-Version: 1.0
Main-Class:Dot
command used for creating jar file
jar cfm dot.jar MANIFEST.MD *
While executing generated jar it throws error saying no main manifest attribute
While seeing inside the generated jar META-INF folder contains auto generated manifest file, it doesn't have content for my main class.
I couldn't find successful steps ,Please correct me.
Had the same issue a few days ago and couldn't resolve it with the manifest file so I put the main class as a build parameter like this:
jar cfe Main.jar MainClass *.class
Add a space after ':' as in
Main-Class: Dot
Add a new line after the last line, in your case after Main-Class entry:
Manifest-Version: 1.0
Main-Class: Dot
The reason for 2. ist documented in https://docs.oracle.com/javase/tutorial/deployment/jar/modman.html in detail.
I tried below command and it works with the jar produced which i post.
java -cp "jsch.jar;." Dot

Java manifest file altered after exporting project

This question is a follow up of this and this question. I've placed the META-INF/MANIFEST.MF file as suggested to /src/main/resources and exported the project using the following MANIFEST.MF file:
Manifest-Version: 1.0
Main-Class: org.fiware.kiara.generator.kiaragen
there is a new line after the Main-Class entry before the end of the file. The artifact configuration is bellow:
The MANIFEST.MF file in the .jar file is different from the one specified in the resources directory:
$ cat META-INF/MANIFEST.MF
Manifest-Version: 1.0
Created-By: 1.5.0_13 (Apple Inc.)
Why is the Main-Class entry removed?
Simple - it is done due to the build cycle.
First your sorces gets compiled along with your manifest from the resources, second maven writes new manifest, and it gets simply overriden.
If you want to pust some custom stuff into your manifest, and you use Maven, you should rather modify your POM file to create proper manifest insteed of putting one in the resources.
Check following
https://maven.apache.org/shared/maven-archiver/examples/manifestFile.html for custom manifest includement.

Cannot find or load main class from .jar file

So I wrote a project in Eclipse and when I click on the green run button it works fine. When I export it into a jar and I double click on it a quick command prompt appears saying "cannot find or load main class...". I tried everything. I tried renaming registry keys, reinstalling java, changing environment variables and of course turning it on and off again. I read all the other threads on stack and tried everything they suggested. Here is my Manifest file:
Manifest-Version: 1.0
Class-Path: .
Main-Class: main.Main
My Main class is in a package called main.
I'd like to suggest to change the package name into something other than main.
don't forget to make a run configuration, which specifies the name of your main class.
package all the related other jar files into the same package.
run the executable.jar as java -jar YourExecutable.Jar
And if it does not solve your problem, just see my MANIFEST.MF file in my Executable jar file. Maybe it can give you some clue.
Manifest-Version: 1.0
Rsrc-Class-Path: ./ concurrentlinkedhashmap-lru-1.2.jar slf4j-api-1.7.
5.jar org.simpleframework.jar openflowj-0.3.7-SNAPSHOT.jar mongo-java
-driver-2.11.2.jar netty-3.9.0.Final.jar guava-15.0.jar org.restlet.e
xt.jackson.jar logback-classic-1.0.13.jar joda-time-2.2.jar org.codeh
aus.jackson.core.jar org.codehaus.jackson.mapper.jar openflowj-0.3.7-
SNAPSHOT-sources.jar org.restlet.jar logback-core-1.0.13.jar org.rest
let.ext.slf4j.jar org.restlet.ext.simple.jar openflowj-0.3.7-SNAPSHOT
-javadoc.jar
Class-Path: .
Rsrc-Main-Class: etri.sdn.controller.Main
Main-Class: org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader

while creating JAR from eclipse?How to set class path in manifest file ,

I am done trying with all the solutions provided. Please help with this:
I am trying to create an executable jar for my project with manifest file. But I keep on get the error no class found.
My manifest file looks like below and it is in project level. I create a jar from eclipse through export.
Manifest-Version: 1.0
Main-Class: com.tn.gov.runParser.RunParser
Class-Path: commons-logging-1.1.1.jar s.jar t.jar 3.jar j.jar o.jar s.jar util.jar xml.jar xml.jar
When you export your project into a JAR, on the prefrences/config page, under "Launch configuration" would be all the possible Classes to put in Main-Class: Also, you could edit MANIFEST.MF on the Main-Class: line manually.

Categories