I have an ant build that makes directories, calls javac and all the regular stuff. The issue I am having is that when I try to do a clean (delete all the stuff that was generated) the delete task reports that is was unable to delete some files. When I try to delete them manually it works just fine. The files are apparently not open by any other process but ant still does not manage to delete them. What can I do?
I encountered this problem once.
It was because the file i tried to delete was a part of a classpath for another task.
It depends ...
The Ant process doesn't have enough permissions to delete the files (typically because they were created by a different user, perhaps a system user). Try running your Ant script as an administrative user, using Run As.
Windows is really bad at cleaning up file locks when processes die or are killed; consequently, Windows thinks the file is locked by a process that died (or was killed). There's nothing you can do in this situation other than reboot.
Get better tools to inspect your system state. I recommend downloading the SysInternals tools and using them instead of the default Windows equivalents.
Using Ant Retry task has helped me.
I've just wrapped it around the Delete Task.
You don't say if your build is run as the currently logged on user. If not, the fact that explorer.exe or other process has the directory shown can cause it to be locked as well. But deleting it in that same explorer.exe process would succeed. Try Unlocker from http://ccollomb.free.fr/unlocker/ to see what processes have the files/directories locked.
Is there something from the Ant process that is holding the files (or directory) open? This would cause the situation where you could delete them after running ant, but not during.
I faced the same problem.
I didn't have any classpath set to or antivirus running on my machine.
However, the ANT version I was using was 32 bit and the JDK I installed was 64 bit.
I installed a 32 bit JDK and the issue was resolved.
Ant versions before 1.8.0 have a bug which leads to random errors during delete operation. Try using Ant 1.8.0 or newer.
You can see the bug details here https://issues.apache.org/bugzilla/show_bug.cgi?id=45960
In my case my ant clean was failing from Eclipse, unable to remove build files. I see this from time to time. Usually succeeds on a repeat attempt. This time no.
Tried running ant clean from command line, failed Unable to delete"unable to delete".
It must have been Eclipse holding on to the problem file, when I exited Eclipse, cmd line was able to delete OK.
I've been having this problem a lot lately and it's random. One time it works, the next time it doesn't work. I'm using NetBeans (in case that matters) and I've added a lot of extra tasks to build.xml. I was having this problem in the -post-jar task. It would happen when I call unjar on the file, then delete. I suspect that NB is trying to scan the jar and this causes the lock on it.
What worked for me is to immediately rename the jar at the start of -post-jar and add a .tmp extension to it. Then I call unjar on the temp file. When I'm done I rename back to the desired jar name.
I too had the same problem and was tried of manually deleting the build directories. Finally I solved it by renaming the .jar artifact of my project to a different name from project name itself. For ex: my project was portal and my ant built script use to generate portal.jar, where eclipse ant was not able to delete this portal.jar. When i changed my build.xml to generate my .jar as portalnew.jar, eclipse was able to delete this portalnew.jar next time. Hope this helps.
You need to delete it manually in Windows. It worked for me. (Usually the files to be deleted are older versions of jar.. For example: if there exists httpcore.4.2.5.ja5r and httpcore.4.3.jar, it will try to delete 4.2.5.jar)
i faced this issue as the file the ant was trying to delete was being used by some other service/process.
I stopped the service, and then the ant build script did run through.
In my case, I stopped running Java process from Task Manager and re-run the Ant build file. The file was able to delete and build was successful.
I am seeing problems like this way too often since I switched to Microsoft Windows 10. Renaming the file immediately before removing it solved it for me:
<rename src="file.name" dest="file.name.old"/>
<delete file="file.name.old" />
For me, I am using mac so I tried sudo before ant cmd, sudo ant clean all and it did work perfectly fine.
As i've read javac will not have access to delete JAR files so you can either sudo it or find alternative.
Related
I have an AEM jar file AEM_6.5_Quickstart. I am trying to get it running but facing issues.
First thing is my jar is not identified as normal on my system like other jars, as you can see there is no icon associated with my jar file.
Second is when i double click on it to run it i get the below prompt to choose the program to run it with, which ideally should not appear. I was getting errors when i was running maven command to generate project using zulu jdk so i had installed jdk from oracle website, now that is removed from my system and when i double click on jar file i still get the option to run it using oracle jdk
Third problem which i am facing is that when i run the jar using zulu x64 Architecture as in above image it starts the jar but i get the below error when i go to localhost:4502
i google searched for solutions and found that indexing might be the problem so i deleted the file at crx-quickstart/repository/index after stopping the jar. When i restart it it gets stuck and doesnt start for some reason as in below picture, the progress bar doesnt move even though i waited for hours. I also made sure that sling authenticator service was running.
This is the output in case it helps for the java version being used and the path is setup as C:\Program Files\Zulu\zulu-11\bin. I am unable to fix this issue, any help is much appreciated.
First, delete the whole crx-quickstart directory (since this is a local environment being set up for the first time), and this way you will have a clean start. After that, maybe the .jar extension is missing from the filename, please add it. Finally, it is easier to use a .bat or .sh script (you can customize parameters and runmodes for AEM). But for a first run, quick setup with the default sample content, just try java -jar AEM_6.5_Quickstart.jar
It seems like windows messed up with your java versions, you can go and fix your windows JDK references from the registry, you can do that by pressing win + R then type "regedit", once open look for the next value:
"HKEY_CLASSES_ROOT\jarfile\shell\open\command" then open the "default" value and check that your path is correct, mine for example is :
"C:\Program Files\Java\jdk1.8.0_202\bin\javaw.exe" -jar "%1" %*
use mine as reference only change the first part between quotes for your path to the JDK.
Usually that should fix it, but some times there are some other registry references that ruin your jar files association, if you can open PowerShell/cmd or bash terminal type java -version and get the proper version of your Java installation, another workaround can be opening terminal, navigate in terminal where your jar lives and then type
java -jar yourJarFile.jar
I used to work on an IntelliJ project that was started before I started working on it. This project had a configuration that allowed me to generate an EXE file that could easily be sent to windows users.
It would generate a massive EXE file bundled with all the needed JARs of the application, and upon running it the first time, it would silently "install" itself into the AppData folder, as if it were a regular windows setup file, even though the user would not even notice it doing that installation.
I am trying to configure a project in IntelliJ to do the exact same thing, but first I have not been able to output the exe file by selecting "exe" as the Java FX native bundle type. It just generates a .jnlp and .jar file. When I select "all", as per some other post here in stackoverflow, it generates an exe file, but only with a few kb in size, which does not contain any of the .jar files that should be part of it. Moreover, when I try to open it, it just crashes saying the main class was not found.
Am I missing some setting for building the project? I am using IntelliJ 2018.3.2
Here are some screenshots:
I have been able to get past this error, after changing the verbosity of the compilation and going through the logs.
There was a log message which helped fixing this:
The process complained about the Inno Setup Compiler missing, which was right. Makes me wonder why IntelliJ would have that feature built in if it depends on external tools but does not notify the user clearly of this.
Detected [iscc.exe] version 0.0 but version 5.0 is required.
After going to the Inno Setup site, downloading and installing the tool, I was able to get the executable to be generated.
Now I am struggling with another error, which is the executable complaining about the main class referenced in the Artifact not being found, but at least I have moved past the first problem! Going to tackle this one now...
The best solution for this is using exe generator software.
There is plenty of exe generators out there.
EXE4J is the most simple & easy tool to use.
In EXE4J,
You can upload your main jar file and select the main class.
I think this will be solved your problem.
This may be due to you`ve extracted Jars to your output root, while you neet to Put it(you can check difference by deleting everything from your output root in Output Layout screen and then just right click on jar on the right side, you will see two options here, try another one
My project needs periodic source downloading from a shared drive. That is in the form of a zip file. After extracting them, I need to checkout some sources from SVN as well. But time shouldn't be spent during office hours for that. Hence a bat file is created which does all these including zip downloading, extraction, SVN checkout, compilation and opening eclipse.
In the process of compilation, I get the following error
unable to access jarfile /plugins/org.eclipse.equinox.launcher_1.3.0
But this is bypassed and eclipse is opened without the option "Build Automatically" checked. Because of this the workspace doesn't get compiled and hence need to spend sometime for building the workspace.
Any idea to set the Build Automatically true without manual intervention?
Otherwise it would be appreciated if the source files could be compiled without the above said error.
Thank you
You should probably not use Eclipse to build your project in a batch process. First, you run in the type of problem you are describing, but you also have the problem of the additional overhead of running eclipse, and this make your build system very platform-dependent.
A cleaner solution would be to call javac from your batch process. See the doc here. Also a useful post here.
An even better solution would be to implement your build script in Ant, instead of batch. Ant is supported by Eclipse, but can be run independently on any platform. It supports doing everything you describe in your build process:
Downloading: Get task
Extracting: Unzip task
SVN checkout: SVNAnt
Compiling: Javac task
Jar: Jar task
etc...
When I try to clean my projects I am now getting two errors that stops the build process...
Could not delete: D:\myworkspace\library\bin\library.jar.
Could not delete 'D:\myworkspace\google-play-services_lib\bin\google-play-services_lib.jar'.
I am running Eclipse as administrator on my Windows 7 computer.
I have been updating all of my libraries recently in order to use Google Cloud Messaging but I have no idea if this has anything to do with it.
If I delete the jar files manually, then start eclipse and clean it will run ok. But now I need to do this anytime I want to recompile.
I have googled this error but I can't find anything on it.
Thanks,
Gary
When you get the error in Eclipse, try using Process Explorer or similar tool to try to determine what running process is holding on to that file.
This is my first question, so apologies for any mistakes. I'll try and give all the info I can. Basically I've written a simple swing application which just loads in image into a JPanel and displays it. I'm using Netbeans 7.1 and I have the latest version of the Java SDK.
Anyway, I've used the "Build" feature in NetBeans 7.1 to deploy my application into a Jar file. When I double click the Jar File on my PC, it runs without a problem. However when I put it on other computers (Tested on 2 others so far, both with the most current JRE) it fails to open, citing the following error:
could not find the main class: swong.Startup. Program will exit
swong is my package name, and Startup is the location of my main method. I have checked the manifest file which is created with Netbeans' build, and it[the manifest] does indeed contain the location of my main method class.
From searching, I've come across similar issues in which the classpath is set wrongly, but I don't understand how this could cause my particular error.
If someone could help me, I would be over the moon. I've been studying java for a year or so, and I've got a good handle down, but I've NEVER been able to make a Jar that runs on a computer which wasn't my own. So, 10 points and thanks in advance.
xo.
EDIT: Thank you for the responses. I'm doing shift work and swamped, but I will test and poke with these responses tomorrow and provide more information. Thanks again. xo
I had d same problem while distributing my app. There is 1 solution that you create a batch file with 'java -jar AppName.jar' and asking user to double click on this batch file to execute your app. What i did was to provide a JRE installation exe(eg: jre_1.7.0) with your app.
Now create a Batch file (install.bat) in which write following commands
jre_1.7.0 -> this will install jre on user's pc
set path="C\Program Files\Java\jre_1.7.0\bin"
java -jar yourAppName.jar
Why i installed JRE because different people have different JRE versions installed. So this makes it difficult to set path to the installed JRE's bin folder & calling the 'java -jar' command. Hence as you know which folders your JRE installation will create hence it is easy to set path and execute your jar file with 'java-jar' command.
Check that your jar file has the following structure (at least)
jarfile.jar
|---------- swong
|---------- Startup.class
|---------- META-INF
|---------- MANIFEST.MF
It seems like the class "Startup" is missing. Maybe your jar only contains the .java files, not the compiled classes.
This error message can be a mistakable java7 error, when you try to start java7 compiled classes with a different Java Runtime Environment then java7. Have you validated, that your .jar is started within a Java7 environment on those other test machines? Sometimes it happens, that you have installed different versions of JREs and you might not be sure which one is actually started.
To check which enviroment is used, you can check in your registry for the following value:
HKEY_CLASSES_ROOT\jarfile\shell\open\command
this should point to your latest JRE. Or if you'd like to stay compatible to java6 as well, define the appropiate compile level in your build environment.