File Not Found Error Using Scheduled Tasks - java

I am trying to run a .jar file from Scheduled Tasks (Windows 2008 Server) and I am getting a file not found exception. My program searches for an .xls file, converts it to a .xlsx file, extracts data, deletes .xlsx file, and uploads info to our database.
Things I've tried:
Running the program directly in the command prompt - Success
Searching for the file using dir in Cmd Prompt - Success
Putting .xls file on Desktop and Running Scheduled Tasks - Success
FileNotFound Exception throws error with correct path to .xls file
Possible Issues:
Could there be any admin privileges not allowing me to access the file from Scheduled Tasks? Why would the .jar file work from the Cmd Prompt but not Scheduled Tasks?
Thanks guys for your help. Willing to upload more information if it helps.

Figured it out! When I use T:\ in my path I am referencing a mapped drive. My scheduled task was meant to run when I wasn't logged on. Of course T:\ wasn't going to be recognized. What I really needed to use was the UNC Path! To find the actual path of your mapped drives type in "net use" into the cmd prompt.
This helped me oceans!
Windows 7 scheduled task "runs" but doesn't DO anything

Related

Running Batch File Using Java ProcessBuilder does not recognized Network drive

I have a java program (jar) that uses ProcessBuilder to execute a dynamic batch file.
Process process = (new ProcessBuilder(commands)).start();
I have a simple batch file like this, Z --> is a network drive. let say my batch file location is in my_batch.bat.
copy Z:\Download\*.csv D:\Download\
if I execute this batch file from the command prompt, it run successfully. But if I execute using the java program, the program does not work (nothing happen). But if I change the batch file like below, it works. E-> is a regular drive (not a network drive).
copy E:\Download\*.csv D:\Download\
I don't know why this can happen, please help.
My Operating System is Windows.
I solved it by putting this line in my batch file.
net use Z: \\Computer\shared /user:DOMAIN\username password
and after the process, use this at the end of my batch file.
net use Z: /d
thanks to the man that help me in the comment section.

Could not open jmx file while running JMeter command line

I have run a thread group in JMeter in GUI mode it is working and getting results, but while running same ThreadGroup.jmx file through terminal(Non GUI] mode,I am getting an error Couldn't load .jmx file.
Can anybody suggest me how to resolve the issue.
In linux using files is case sensitive, so use exact letters(as sampleThreadGroup.jmx)
Also make sure the file is saved in the correct folder
And check your user have permission to execute it (try chmod 777 for jmx file)

Java Process cannot delete files in use

My Java application runs on a Windows service wrapper and the wrapper writes logs into a DEBUG file. The application has a service that backup and delete this DEBUG file at the end of the day. The service uses a script batch file to do this process.
My problem is, when the application try run this batch file and delete the DEBUG file following error occurs,
The process cannot access the file because it is being used by another process.
But if I run the batch file or run the relevant script manually everything works well. Is there a way to solve this problem without stopping the wrapper? (Tried to truncate the file but got the same error)
Script I use : DEL /A /F /Q "C:\MY_APP\logs\DEBUG.DMP"
Thanks!

java.exe is not recognized as an internal or external command

I have already read some posts but I cant solve my problem yet.
I am working on a remote desktop and windows server 2008. In the shared disk E: I put some batch file. This batch files call a new batch file from server which runs java script. And now I am taking the this message.
java.exe is not recognized as an internal or external command, operable program or batch file.
I try to set the environment like :
First setup the JRE7 to disk E
Second create new user variable which name is JAVA_HOME and which path is my JRE path E:\Tool\BatFiles
But I am still taking this error. Where should I do wrong ?
Setting JAVA_HOME is a good step, and with it you should be able to run Java as follows
%JAVA_HOME%/java myProgram arg0
If you don't want to include %JAVA_HOME in your command, you will have to include it in your PATH. Windows checks it's PATH for bin scripts every time a command is called. A typical Java installation does this for you.
You can edit your PATH to include ;%JAVA_HOME% at the end. Restart your command prompt for changes to take effect.
Edit 1
Be careful when editting your PATH however! Windows depends on it to function in many aspects. You can expect explorer to stop working. Make sure before altering your PATH variable, that you back it up somewhere. Just in case.

JAR issue on Windows 2003

I have an application (myapplication.jar) running on Windows 2003. The application was running fine few days back on this server.
I am using a bat file to execute the Jar applicatin, for some reason it stopped working on it and I am unable to find the why?
If I copied the same folder to another server where JRE is already installed it works without an issue.
Cansome suggest me how do I find what is the issue. I have already checked the file type association, delete the temporary files (java cache and temporary files in windows)
Thanks in advance!!
Without any log, exception or stack trace it will be impossible to know what is causing the problem. Open the bat file in an editor and add at the end of line that starts with:
java -jar yourProgramBundledInA.jar > yourApp.log
this is going to redirect the console to yourApp.log file. Save the bat, run it and then look up the content of yourApp.log. There should be a clue why the application is failing.

Categories

Resources