javac with MigLayout - jar

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!

Related

Qt renaming path of the project

sometimes when I rename the path to a qt project, it cannot be run even though I clean qmake and rebuild it!!! the path does not contain any space. and the project is completely correct and I know that the error is for path renaming , for example when I rename :
D:/abd/projects/LAND_2/Land_QT/...
to
D:/abd/projects/LAND_2/Land2_QT_SA/...
it cannot be build and says that some include file is missing(but the file is there!).
what is the problem?
I work with dynamic qt5.2 on windows 7.
Edit:
when I copy the project folder to a new directory( a path upper than current path) then the project can be build and run.
When you rename the path to the project, go to the project folder and delete the file with .pro.user extension. Open the project and Qt will ask you to configure the project. Choose the required kit, build and run the project.It should build successfully now
If you have changed path multiple times the .pro.user file is created multiple times delete all files with this extension and compile

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.

Applications works while debugging, but doesn't work when "released"

So, I just made a standard, QtQuick 2 application, it has the default Recangle, Text and MouseArea. So, I just tried to compile the application in release mode, to see what files it would generate, and then I tried opening the application and this happened:
When I resize it, I cans see white space:
However it all works fine in debugging:
I am using Qt 5.0.1 and QtQuick2
Update
So, after running it through Dependency Walker it appears like there are three files missing: qt5quick.dll, qt5gui.dll, and qt5core.dll. Do I have to manually add them from somewhere?
The current directory structure is:
`test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release/release
|+qml
|+test
|-main.qml
|-main.obj
|-moc_qtquick2applicationviewer.cpp
|-moc_qtquick2applicationviewer.obj
|-qtquick2applicationviewer.obj
|-test.exe
|-test.exe.embed.manifest
Note: I pasted the qml directory as suggested in Nemanja Boric's answer from the parent directory, but that didn't solve the problem! :(
Also, I was under the impression that none of the source (apart from JavaScript maybe) wouldn't be openly distributed with the app, but compiled or packed inside the application somehow (note the .cpp file and the qml directory)?
Update 2
The application works just fine when run from inside Qt 5 Creator:
Starting [...]\test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\test.exe...
QOpenGLShader::link: "(41,18): warning X3206: implicit truncation of vector type
"
[...]\test-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release\release\test.exe exited with code 0
Well, apart from that one awkward warning...
You need to copy qml files into your current directory. When you create release application with QtCreator, you will have this directory structure (or something like this):
example-build-Desktop_Qt_5_0_1_MSVC2010_32bit-Release
|- debug
|- qml
|- release // application executable is here
What you need to do is to copy qml folder to be in the same directory with your executable release file (simply copy qml folder into release folder).
About dll files - you can copy them manually from QtInstallDir/bin folder or you can add that directory into PATH, if you are developing on that machine - it could be easier.
You don't need to publish cpp files, but you need to publish qml files. What you can do, through I never succeed, but it seems to be possible is to bundle qml files into Resource file, and to load it from resources, but that can be extracted easily, too - so - don't put your logic or confidential informations in qml files.
Also, you need to copy all required dll files into directory with exe: qt5quick.dll, qt5gui.dll, qt5core.dll and libEGL.dll.

Qt Creator could not find the executable, please specify one

I'm trying to run the texteditor.pro file in the QtSDK\Examples\4.7\tutorials\gettingStarted\gsQml directory with Qt Creator. When I try to build the project I get a window that says
Could Not find the executable, please specify one
with three fields to load files. Snapshot of the dialog box.
I'm running windows 7 64bit, with Qt Creator 2.4.1
I've solved the problem it was a missing dll file, but the executable didn't ask for it, so I put all the dlls from Qtcreator -> bin in the same folder with the *.exe file, then I deleted file after another until I figured out what files are required.
* It is a brute force way, but It did the job.
* Here is the file that were missing (libEGL.dll)
This project is not created in the normal 'Qt-executable' kind format. Rather its a 'plugin' kind project. So you cant run it directly like other projects.
[If you will open the project files you wont find a main() function!, which is supposed to be the entrance point usually for a C++ Application. All you have are a couple C++ classes. Take that as a hint]
About this example they have given the complete details here. And I quote:
We need to compile the file dialog C++ plugin before the text editor
can run. To compile, enter the gsQml directory, then run qmake and
compile using make or nmake, depending on your platform. To run,
launch qmlviewer and open the texteditor.qml file.
Else:
You create your own project.
Add these class files and the respective qml files to this project.
Add a main and create the respective objects required.
Make an application viewer and give "texteditor.qml" path as its source.
I had the could not find executable window pop up in my face in Ubuntu 12.10.
Here's how I got the "error":
Created a folder named Project;
Inside it, I ran "qmake -project" and then "qmake";
Created a main.cpp file inside the folder;
Opened the Project.pro file with Qt Creator and added the line "SOURCES += main.cpp" to it;
Pressed Ctrl + R to build and run the project.
Later on I deleted the folder and created it again, but this time creating a main.cpp file before trying to run any commands. I opened the .pro file with Qt Creator, created a main function in the main.cpp file, and pressed Ctrl + R, and it built and ran!

Qmake does not support build directories below the source directory

I have created an application that compiles and runs like a charm on OS-X. I would now like to start getting it to work on Windows. To start, I copied the project to a windows machine and just tried to compile, but got this error:
:: warning: Qmake does not support build directories below the source directory.
Any ideas?
Set the shadow build directory to some folder on the same level of your project directory:
folder/
project/
project-shadow-build-release/
project-shadow-build-debug/
You can do this in the "Projects" view, via the toolbar on the left. To me, this warning was just an annoyance, a project never failed to build because of it.
Don't copy your project.pro.user file when you are copying a project from one machine to another, or from one directory to another. When you open the project, Qt Creator will offer to create a new build directory in the proper place.
Andref gave the correct answer to resolve this warning, but you may want to understand why this requirement exists.
In fact, the build directory must be at the same folder level as the project (i.e. it can't be above or below). The reason why is that the linker is called from the build directory. Hence, any relative paths to library files will be different than what you entered in your project file.
It kinda sucks. I like to put all intermediate files in their own folder. But you simply can't with qmake.
.pro.user are generated files by Qt Creator. They are unrelated to qmake and should not be touched (and not put into a VCS for that matter)
Just remove the files with the pro.user extension , worked for me
I also got this, trying to compile a project created on linux.
Another way to solve it is to change the paths in the .pro.user file (in the directory of your project)
Right Click on a project: Set As Active Project
Click on the Projects button (The one with the spanner image)
Edit build configuration : Debug / Profile / Release / and change the default directories, OR just uncheck the Shadow build check box.
The Build directory path should now change to black, from red

Resources