no main manifest attribute - jar

Any .jar file I export from eclipse does not work. I keep on receiving the "no main manifest attribute" error when I try to run the .jar file from command prompt.
When I try and double click the .jar file it does not run. Exporting the file itself is simple, there are plenty of tutorials for this, but the .jar wont run.
Is there a step by step solution to this problem for beginners? I looked through different forums but I do not undertstand how to fix it. I export a class called "test2.java" under the name "hello"

Related

Why I get a QmlCachedGenerateCode when I tried to create a new qml file?

I tried to create a new qml file in my project, but when I run it shows me an error message "undefined reference to QmlCachedGeneratedCode", but I checked and the file that I created was added in the qml.qrc file, I don know how to fix this error, I tried clean my project, but it didnt work.
I run git clean -f to clean the cache, but it still does't working, so I clone again the repository and it works, I don't know why.

javac with MigLayout

I've spent the past week trying to figure this issue out...hopefully someone can help.
I created a Java project that uses MigLayout. I've added the jar file to the same directory where my main class is.
i.e.
java/
Main.java ...contains main() method
MigLayout/miglayout-4.0-swing.jar
It doesn't matter which editor I use, I can compile/run the file and it executes flawlessly.
The issue starts when I try to create a jar file, or compile with cmd. If, for example, in IntelliJ I build the artifact (build the Jar file), it builds it...but it won't run it when I double click on it.
If I use javac in cmd, it gives me this error:
/////////////////////////////////////////////////////////////////////
Main.java:8: error: package net.miginfocom.swing does not exist
import net.miginfocom.swing.MigLayout;
^
Main.java:74: error: cannot find symbol
menuPanel = new JPanel(new MigLayout());
^
symbol: class MigLayout
location: class Main
2 errors
//////////////////////////////////////////////////////////////////////
Any help would be great.
SOLVED
OK, so I got it working. This is what I did:
I created a new folder and moved all of the src files into the src folder there
I made sure to remove all other files that weren't java related, such as the Manifest file
I previously downloaded the MigLayout and json jars and placed them into the src folder as well (that's how I originally got the code to compile)
I opened up IntelliJ and clicked File -> New -> Project from existing source
I selected the folder that contained the src folder
I ran through the prompts. I noticed that it was finding everything: MigLayout and JSON jars
After it was complete, I made sure that it would compile in IntelliJ and it did.
Next, as I did before, I clicked File -> Project Structure -> Artifacts
I clicked the Plus button and selected JAR From Modules with dependencies. I selected the file containing the main method
I checked the Build on make option that's right below the Output directory
I clicked Apply and OK.
Next I clicked Build and Build Artifacts
I selected Jar and Build Jar
Went to the out folder and it was there
I double clicked on it and everything worked!

Working directory error

I am working with PyCharm 4.04. Since I installed it, every time I open it, as default directory I get this:
C:\Users\Laura\AppData\Local\Temp\main.py1.tmp>cd
Which gives me an error when trying to use the console:
Error:Cannot start process, the path specified for working directory
is not a directory
But even if I change the directory, the message does not disappear.
The terminal, though, it does work and I can run projects, but I would like to use the console.
Another solution is to close the project, run rm -rf .idea and re-open it. Apparently Pycharm gets confused by some direct folder manipulation and doesn't reflect it properly in his .idea/*.xml files
I also got this error, and it got resolved by setting the default working directory. Follow the below path, and set the Working Directory to the folder where your code resides.
File > Settings > Build, Execution, Deployment > Console > Python Console > Working Directory ...
I finally solved the problem.
I think it all started because the first project that I opened with pycharm was in my "download" folder, so the working directory was automatically set to a temporal folder by default and allthough I moved the project to another folder and I manually changed the working directory from the terminal, it was not working.
The solution was creating a new project and giving a correct path to the new project. It seems very easy but it was not that obvious.
In the upper right corner click on small ▼ next to your main to run (look to the left from green right-pointing triangle)
Select Edit configurations.
In ▼ Python select the proper configuration name.
Look at the Configuration panel.
Fix items Script and Working directory.
pycharm
I had this same problem and just had to reinstall pycharm. It's a quickfix and I can't ensure it won't happen again.
I solved this by replacing all instances of the old filename and old directory with the new one in .idea/workspace.xml
It can be done with PyCharm running.
#user1068430 has the answer in the comments to the question:
When you open a project open the directory not a specific python file.
Instead of ~/Documents/myProject/main.py open ~/Documents/myProject
If you "open" the .py file then you'll have to set the working directory (File > Settings > Build, Execution, Deployment > Console > Python Console > Working Directory) every time. If you "open" the directory containing the .py file, then PyCharm will open and all of your .py files will be available in the left window. Select one of them and you're good to go.
i had the same issue, the error comes up when i want to upgrade my packages and when i run my project "this FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\youruser\AppData\Local\Temp\gen_py\3.7\__init__.py'" i found that the Temp file in C:\Users\youruser\AppData\Local was corrupt and it was fixed by deleting the "Temp" file, once deleted it will automatically create a new one with "gen_py" in it
To anyone with similar issues: Python interpreter virtual environment is where your python.exe sits. The working directory is where your script sits. To make everything easier, open a new project, scroll to location where you script is stored, and select. Click the interpreter option, click existing (if old one worked) or choose the python.exe. When asked, open the project in a new window, close old one to avoid confusion.
source = banging my head against the console for past few hours.
if the above mentioned solutions are not working, you can restart a new project.
file > New project...
then,
create a new project.

Package does not exist - error

I am trying to compile a .java file (TransformRTDE.java) that uses several import statements. These statements import .class files present in five external JAR files: dataextract.jar, jna.jar, JRI.jar, JRIEngine.jar and REngine.jar. I have read documentation on how to deal with these import statements while trying to compile your .java file from the command line. However, I do not seem to succeed.
I set up the directory in the command line to be the folder in which my .java file resides. In that same folder, I have put the JAR files. When I try to compile the code using java -cp dataextract.jar jna.jar JRI.jar JRIEngine.jar REngine.jar TransformRTDE.java, I get a package does not exist error. I have set up the class path to include the folder in which all my .java and .jar files reside.
I have searched for hours on this without success. Any ideas what I'm doing wrong?
Thanks in advance!
EDIT: I forgot to mention I also get an error related to annotation processing.
Picture can be found here: https://www.dropbox.com/s/p9ul0olydzmkl6s/error.png

jar file not found iexpress

I am using iexpress to make my .jar files into .exe files
for this I add the jar file(myjarfile.jar) and in run command box I type : java -jar myjarfile.jar
but after creating the .exe the cmd that is flashing says cannot find the jar file myjarfile.jar
can any body help me find what I am doing wrong
To test this, I built a simple HelloWorld.jar file (using these instructions) and tested it like so:
java -jar HelloWorld.jar
Then I made an IExpress package with it. The Install program was exactly the command I used above. This worked exactly as it should.
Two possible causes of the error:
In the IExpress wizard, there's a checkbox Store files using Long File Name inside Package. You should definitely select this option; ignore the warning that appears, as it applies to Windows 95/98. In the .sed file, this is:
UseLongFileName=1
Check that the .exe actually contains myjarfile.jar. 7-Zip will open the .exe and show you the archive contents. (IExpress .exe files are just a CAB file with a wrapper.) If the file is missing, then you'll need to check your .sed file to see what went wrong.

Resources