File Not found exception in opening a jar file after i make the jar file using command line arguments - java-me

The problem statement:
I have a J2ME app and i have a separate struts program running. The program automatically changes the source of the J2ME app an then builds it, pre-verify it, and then package it using command line arguments. To achieve all this i have used "Runtime.getRuntime().exec" in my program. Problem is that if i introduce a delay of one sec before the command for packaging is executed, the jar file is still formed BUT accessing the jar file using the command "DataInputStream in = new DataInputStream(new FileInputStream(f));" gives me File Not found exception. "f" is the path to the jar file and i have checked it using "f.getCanonicalPath()" that its the right path.
I don know what the problem is. Please help me. I thank you in advance.

Are you waiting for the Process spawned by Runtime.exec() to complete before accessing the jar file? You can use Process.waitFor() for instance to halt the execution of your thread.

Related

Getting error level of a bat file when running it from Python

I have a .bat file that calls different things and runs different scripts to compile and build a system developed by other programmers.
I am trying to call that .bat file from Python using Qprocess. The bat file runs smoothly. However, if the bat file by some reason fails, my python script needs to be terminated in some way.
I had a short discusion with some of the guys that wrote that huge .bat file and they told me that the .bat file has a standard structure and returns error levels if something is failed.
I don't really know how to catch those levels and I don't know so much about batch programming. Is Error level something universal? Can it be catched from Python?
I googled a bit and I found some very old articles that didn't teach me so much. Any one has a short example on how to catch those levels?
Error level in a batch file context means it will exit with a certain code. You can query this exit code as soon as the process finished.
def properties(self):
self.process=QProcess()
self.process.finished.connect(self.onFinished)
self.process.start('test.bat', ['arg'])
def onFinished(self, exitCode, exitStatus):
[check exit code here...]

Python ImportError when executing through windows scheduler

I did some searches for this topic and found some prior threads, but I did not understand any of them as I am still a total beginner in Python.
I have a Python script which has some long string variables stored in various .py files in a sub-directory. I'm importing the .py files from that sub-directory when I run the script. There is a __init__.py file in the sub-directory. The only reason I'm using this setup is that the long string variables which I'm storing in those other files would make the code very difficult to read as they are SQL strings and can span 50-100 lines each.
Everything works perfectly when I run this script through PyCharm.
However, when I run the script through Windows Scheduler or a batch file, I get an ImportError for all of the .py files in the sub-directory. The problem is definitely related to the python script not knowing where to look for those .py files when it's run through Windows Scheduler. But I'm not sure how to fix it.
The action for the scheduler task is to run the python exe
D:\Python35\python.exe
with the argument as the script
D:\python\tableaudatasourcebuilds\dcitechnicalperformance\dcitechnicalperformance0.py
So the full action looks like:
D:\Python35\python.exe "D:\python\tableaudatasourcebuilds\dcitechnicalperformance\dcitechnicalperformance0.py"
The subdirectory which stores the long string variables .py files is:
D:\python\tableaudatasourcebuilds\dcitechnicalperformance\dcitechnicalperformance0\
The imports look like:
from dcitechnicalperformance.dcitechnicalperformance0.dciquer import nzsqldciwk
Does anyone know how to address this problem? Any help is much appreciated.
Good afternoon,
First of all i don't know how much sense there is to store long SQL querys on a module, I'm not by any means an expert, but something like a JSON file (or hell, even store them in a table inside the sql) seems like a better approach.
About your problem I think it resides on the current directory where the task is launched, let me explain:
In PyCharm when you run the code it launches from the location of the file, and with so, it's able to find the directory with the module.
With the scheduled task it may be launching in another directory and so, it's unable to find the module as the directory is not present.
If you decide to stick with your reproach a plausible solution would be to create a .bat file that browses to the project location:
#ECHO OFF
D:
cd D:\python\tableaudatasourcebuilds\dcitechnicalperformance\
D:\Python35\python.exe dcitechnicalperformance0.py
And that should work.

Is there a way to invoke own version of node.js on Node startup?

I just started playing with node debugger and noticed a node.js file which is invoked at the very beginning of node execution.
As the comment in the file says
This file is invoked by node::Load in src/node.cc, and responsible for bootstrapping the node.js core.
I'd like to change content of this file to something else (yes, I know there's no need to do that), is there a way to replace content of that file / specify path to new file without compiling node from source?
Short answer: Nope.
If I read the source correctly, the file node.js gets compiled into the resulting binary, as a string - the file itself does not exist anywhere on the filesystem so you cannot modify it and, for the same reason, you cannot tell Node to execute your own version of it.
Best look at the sources - mainly the LoadEnvironment method.

Does llsubmit take into consideration the LD_LIBRARY_PATH?

I'm having a bit of a trouble running a job on a nVidia cluster. My code is divided into a shared library containing the cuda code and a .cpp file which calls functions from that lib.
The thing is that when I submit the job (llsubmit) I get an error message telling me that ".. cannot open shared object file: No such file or directory"
I've tried adding the path where my .so file is located using the LD_LIBRARY_PATH variable but it still doesn't work.
Could I specify this by adding an entry in my .cmd file?

groovy File not found error when file exists

I am trying to access a file on my computer using the following code:
new File('c:/test.txt').eachLine{
line->println line
}
I know the file exists, why do I see an error that the file is not found. Is this maybe an issue with my groovy install?
This has nothing to do with the code or your groovy installation.
Recheck the file extension. If you are on Windows 7, the file extensions might be hidden while viewed in the Windows Explorer.
Also, it is better to respect the case sensitivity of filenames, if in case you are working on a Linux machine (which I assume not).
Or perhaps it could also have something to do with file permissions if in case your stack trace looks like this:
java.io.FileNotFoundException: (Permission denied)
If you pass JMS params (-Xms -Xmx etc.) to the groovy command you would get that result. You can find the full explanation here.

Resources