I am trying to run a project that requires a specific file for proper execution. So far I have hard-coded the path to that file in the Run configuration's command line, but I would like to use a special project variable for that, that points to the actual directory the project is in.
Example (run command-line):
Now: /home/user/netbeansproject/myProject/myspecialfile.gz
Expected: ${project.dir}/myspecialfile.gz
Is this possible in Netbeans and if yes: how and where are those parameters documented?
Try this!
if (new File("myspecialfile.gz").exists()) {
System.out.println(new File("myspecialfile.gz").getAbsolutePath());
}
I would pass the path to main method with command line arguments when the application starts.
if (args.length > 0) {
System.out.println(new File(args[0].trim()).getAbsolutePath());
} else {
throw new IllegalArgumentException("Configuration file needed to"
+ " run. Provide configuration file's path as argument.");
}
But maybe this solution is not what you're after.
EDIT:
Well if you define new "Run" configuration in your project properties and save it, then it is saved to ..NetBeansProjects/YOUR_PROJECT_NAME/nbproject/configs/your_configuration_name.properties
In that file you can define your commandline arguments like this:
application.args="/somepath/NetBeansProjects/SomeProjectName/myspecialfile.gz"
I don't believe you can add ${somedir} reference to it.
Related
I am coding a hashing program in ada and using direct io to read and write to/from a file. I am trying to read from a file that is in the same folder as the executable as it should be but still raising the exception. Any ideas as to why its still raising this exception?
adb showing exception driver ads file
The location of the executable has no impact on the interpretation of the names of files to be opened or created. The relevant issue is the current working directory (or folder, if you will) of the process that executes the program. In the common OSes, for a file to be found based on its file-name alone (without any directory path), the file must lie in the current working directory.
You seem to be executing the program from within some IDE, right? Then the IDE probably defines the current working directory to be used when the IDE executes the program. Do you know how the IDE does that, and can you override the default within the IDE? If not, I suggest that you execute the program from the shell command line and manually set the current working directory as needed, in that shell window, using the "cd" command before executing the program.
You could use Ada.Directories (ARM A.16) to work out the location of the data file from the location of the executable:
use Ada.Directories;
Program_Name : constant String := Ada.Command_Line.Command_Name;
Complete_Name : constant String := Full_Name (Program_Name);
Full_Directory : constant String := Containing_Directory (Complete_Name);
Source_File_Name : constant String
:= Compose (Containing_Directory => Full_Directory,
Name => "foo",
Extension => "txt");
Note, the use Ada.Directories meant I had to be a bit 'creative' about variable names; without it, I could say e.g.
Full_Name : constant String
:= Ada.Directories.Full_Name (Program_Name);
It seems like it is impossible to run a process on Scala with another working directory and input redirect.
This is how I would typically run a process on Scala with a default directory:
Process(cmd, new File("someDir")).!!
And this is how I would typically run a process on Scala with input redirect:
("someCmd -someParam" #< "myFile.txt").!!
It seems like it is impossible to combine the two..
Am I missing anythign?
#< is a method on ProcessBuilder, so you can just call:
(Process("someCmd -someParam", new File("someDir")) #< new File("myFile.txt")).!!
Note, that the File you pass as input has to be specified relative to the working directory of the Scala process. But if instead you are passing the file path as an argument to the command, the path has to be relative to the working directory of the command.
So, for myFile.txt inside someDir, the calls may look like this:
(Process("someCmd -someParam", new File("someDir")) #< new File("someDir/myFile.txt")).!!
But,
Process("cat myFile.txt", new File("someDir")).!!
I found a snippet of code that if I paste in PowerShell It displays all of my windows path variables on one line. What would the syntax be for adding this code to my profile?
Push-Location env:
(ls path).value.split(";")
Pop-Location
Put this function in your PowerShell profile:
function Get-Path {
$env:Path.Split(";")
}
After this function is defined, you can type Get-Path to see the list of directories in your Path.
If you don't already have a profile script, run the command help about_Profiles for more information.
Not sure why you'd prefer to see PATH variable on one line, but here's the code to do it.
C:>(ls Env:\Path).value
I prefer separate lines:
C:>(ls Env:\Path).value.split(';')
As far as your PowerShell Profile goes, open PowerShell and run:
C:>$profile
It will tell you the path to your profile (make the file and directory if it doesn't exist).
Then, copy + paste the code above into it.
It will run whenever you open powershell.
Here is my problem. I'm running TestRunner from command line in order not to launch SoapUI client. (anyway, same problem occurs when running TR straight from client, so not sure if worth mentioning but anyways...). I do it this way:
testrunner <path_to_project> -r -a -f <path_to_reports> & pause
In one of my TC I retrieve data from DB, then save it to project properties this way:
testRunner.testCase.testSuite.project.setPropertyValue("key", value);
Then I use it in next steps which works fine. The problem appears in other TC where, firstly, I get filename from my project properties, this way:
def oldFilename = testRunner.testCase.testSuite.project.getPropertyValue("FILE_NAME");
Then I want to use it, rename it and save to project properties again, so that it would be ready for next launch. I do it the same way:
testRunner.testCase.testSuite.project.setPropertyValue("FILE_NAME", newFilename);
It seems to be not saving/storing this value. Is there any way to fix this?
If you modify anything in your project, and you want to preserve that from one run to the next, use the -S (uppercase) switch.
Documentation is your friend. :)
What's the easiest way to cause JsDoc to leave out the source links? Do I have to define my own template?
If you use the default template, then use a configuration file with templates.default.outputSourceFiles set to false. For instance:
{
"templates": {
"default": {
"outputSourceFiles": false
}
}
}
You'd pass the path to this file to jsdoc using the -c option on the command line.
I don't see this option documented in any actual jsdoc documentation. I've found it mentioned in this issue and this one.
The template is the entity providing this functionality so if you use another template than the default one, you have to check its documentation to find whether there is a setting you can set to do this.
In order to remove source file links, we need to create a file named jsdoc.json and add:
{
"templates":{
"default":{
"outputSourceFiles":false
}
}
}
Then run:
jsdoc -c jsdoc.json calculator.js
Here calculator.js is the main file (your actual file that is going to be documented) and jsdoc.json is the configuration file. To run the configuration file I used –c option.
So, basically all you need to do is to just create a file called jsdoc.json and add the above mentioned code and save it. After saving run this command:
jsdoc -c jsdoc.json calculator.js