Problem when I am running java code in the terminal in vs code - classpath

public class Main {
public static void main(String[] args) {
// System.out.println("Hello");
int a = 5,b=6;
int c = a+b;
System.out.println(c);
}
}
When I am running this code in vscode I am getting my desired result i.e. 11 but with that I am getting a huge address of a file in my local computer . Can somebody explain the reason behind that?
The output I am getting :-
k:; cd 'k:\JavaBasics'; & 'C:\Program Files\Java\jdk-11.0.10\New Folder\bin\java.exe' '-cp' 'C:\Users\khushal\AppData\Roaming\Code\User\workspaceStorage\a6084cec5acdec0bc4f5c4be0d94ed8a\redhat.java\jdt_ws\JavaBasics_22fbb3a7\bin' 'Main'
11
I am only expecting 11 but why the address of that file

That's the actual command that sending to the terminal. If you do not want to see them, you can update the setting java.debug.settings.console to internalConsole.
Note: If your program needs to consume user input, you still needs to use the integrated terminal. Internal console will not work for that case.

Related

Could not load file or assembly(dll file path+name) or one of its dependencies. An attempt was made to load a program with an incorrect format

When trying to perform-
Import-Module 'C:\\Program Files\\Nimble Storage\\bin\\Nimble.Powershell.dll'
through program, I am receiving below error:
Could not load file or assembly 'file:///C:\Program Files\Nimble
Storage\bin\Nimble.Powershell.dll' or one of its dependencies. An
attempt was made to load a program with an incorrect format.
The same works when ran directly from Powershell but in the above case, facing issue.
C# program used and have used statement:
Collection< PSObject > resultCollection = runspaceInvoke.Invoke("Import-Module 'C:\\Program Files\\Nimble Storage\\bin\\Nimble.Powershell.dll'", null, out errors);
EBGreen is right. Need to see your code bro. In absence of that, something like the following should work:
using System.Management.Automation;
using System.Management.Automation.Runspaces;
class foo {
static void Main(string[] args) {
InitialSessionState initial = InitialSessionState.CreateDefault();
initial.ImportPSModule(new string[] {"'C:\\Program Files\\Nimble Storage\\bin\\Nimble.Powershell.dll'"} );
...
}
}
Check out Creating an InitialSessionState for more information.

my tess4j in java with a error "Failed loading language 'osd'"

public static void main(String[] args) throws TesseractException {
ITesseract instance = new Tesseract();
instance.setLanguage("osd");
instance.setDatapath("/usr/local/Cellar/tesseract/3.04.01_1/share/");
String tent = instance.doOCR(new File("/Users/qwf/Desktop/111.jpg"));
System.out.println(tent);
}
when i run the code ,there is 2 error:
Failed loading language 'osd'
Tesseract couldn't load any languages!
i don't konw how tess4j find there is any languages can be use
and when i run the "tesseract --list-langs" in iterm
the result is "eng osd"
i think the tesseract works well but why tess4j don't work
i have set the TESSDATA_PREFIX environment variable
echo $TESSDATA_PREFIX
output : /Users/qwf/tessdata/3.04.01_1/
i install tessdata by homebrew
Wrong order: set the datapath before the language.
instance.setDatapath("/usr/local/Cellar/tesseract/3.04.01_1/share/");
instance.setLanguage("osd");

Cudafy chapter 3 example has path issue how to fix?

Using Cudafy version 1.29, which can be downloaded from here
I am executing the examples that are found in the install folder CudafyV1.29\CudafyByExample\
Specifically, "chapter 3" example that begins line 42 of program.cs calls the following:
simple_kernel.Execute();
which is this:
public static void Execute()
{
CudafyModule km = CudafyTranslator.Cudafy(); // <--exception thrown!
GPGPU gpu = CudafyHost.GetDevice(CudafyModes.Target, CudafyModes.DeviceId);
gpu.LoadModule(km);
gpu.Launch().thekernel(); // or gpu.Launch(1, 1, "kernel");
Console.WriteLine("Hello, World!");
}
The indicated line throws this exception:
Compilation error: CUDAFYSOURCETEMP.cu
'C:\Program' is not recognized as an internal or external command,
operable program or batch file. .
Which is immediately obvious that the path has spaces and the programmer did not double quote or use ~ to make it operational.
So, I did not write this code. And I cannot step through the sealed code contained within CudafyModule km = CudafyTranslator.Cudafy();In fact I don't even know the full path that is causing the exception, it is cut-off in the exception message.
Does anyone have a suggestion for how to fix this issue?
Update #1: I discovered where CUDAFYSOURCETEMP.cu lives on my computer, here it is:
C:\Users\humphrt\Desktop\Active Projects\Visual Studio
Projects\CudafyV1.29\CudafyByExample\bin\Debug
...I'm still trying to determine what the program is looking for along the path to 'C:\Program~'.
I was able to apply a workaround to bypass this issue. The workaround is to reinstall all components of cudafy in to folders with paths with no ' ' (spaces). My setup looks like the below screenshot. Notice that I also installed the CUDA TOOLKIT from NVIDIA in the same folder - also with no spaces in folder names.
I created a folder named "C:\CUDA" and installed all components within it, here is the folder structure:

How to execute JMeter test case from Java code

How do I run a JMeter test case from Java code?
I have followed the example Here from Blazemeter.com
My code is as follows:
public class BasicSampler {
public static void main(String[] argv) throws Exception {
// JMeter Engine
StandardJMeterEngine jmeter = new StandardJMeterEngine();
// Initialize Properties, logging, locale, etc.
JMeterUtils.loadJMeterProperties("/home/stone/Workbench/automated-testing/apache-jmeter-2.11/bin/jmeter.properties");
JMeterUtils.setJMeterHome("/home/stone/Workbench/automated-testing/apache-jmeter-2.11");
JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
JMeterUtils.initLocale();
// Initialize JMeter SaveService
SaveService.loadProperties();
// Load existing .jmx Test Plan
FileInputStream in = new FileInputStream("/home/stone/Workbench/automated-testing/apache-jmeter-2.11/bin/examples/CSVSample.jmx");
HashTree testPlanTree = SaveService.loadTree(in);
in.close();
// Run JMeter Test
jmeter.configure(testPlanTree);
jmeter.run();
}
}
but I keep getting the following messages in the console and my test never executes.
INFO 2014-09-23 12:04:40.492 [jmeter.e] (): Listeners will be started after enabling running version
INFO 2014-09-23 12:04:40.511 [jmeter.e] (): To revert to the earlier behaviour, define jmeterengine.startlistenerslater=false
I have also tried uncommented jmeterengine.startlistenerslater=false from jmeter.properties file
How do you know that your "test never executes"?
What is in jmeter.log file (it should be in the root of your project). Or alternatively comment JMeterUtils.initLogging() line to see the full output in STDOUT
Have you changed relative path CSVSample_user.csv in "Get user details" CSV Data Set Config as it may resolve into a different location as it recommended in Using CSV DATA SET CONFIG
Is CSVSample.jtl file generated anywhere (again it should be in the root of your project by default)? What is in it?
The code looks good and I'm pretty sure that the problem is with the path to CSVSample_user.csv file and you have something like java.io.FileNotFoundException in your log. Please double check that CSVSample.jmx file contains valid full path to CSVSample_user.csv.
UPDATE TO ANSWER QUESTIONS IN COMMENTS
jmeter.log file should be under your Eclipse workspace folder by default
Looking into CSVSample.jmx there is a View Resulst in Table listener which is configured to store results under ~/CSVSample.jtl
If you want to see summarizer messages and "classic" .jtl reporting add next few lines before jmeter.configure(testPlanTree); stanza
Summariser summer = null;
String summariserName = JMeterUtils.getPropDefault("summariser.name", "summary");
if (summariserName.length() > 0) {
summer = new Summariser(summariserName);
}
String logFile = "/path/to/jtl/results/file.jtl";
ResultCollector logger = new ResultCollector(summer);
logger.setFilename(logFile);
testPlanTree.add(testPlanTree.getArray()[0], logger);
Try using library - https://github.com/abstracta/jmeter-java-dsl.
It supports implementing JMeter test as java code.
Below example shows how to implement and execute test for REST API. Same approach could be applied to other type of tests as well.
#Test
public void testPerformance() throws IOException {
TestPlanStats stats = testPlan(
threadGroup(2, 10,
httpSampler("http://my.service")
.post("{\"name\": \"test\"}", Type.APPLICATION_JSON)
),
//this is just to log details of each request stats
jtlWriter("test" + Instant.now().toString().replace(":", "-") + ".jtl")
).run();
assertThat(stats.overall().elapsedTimePercentile99()).isLessThan(Duration.ofSeconds(5));
}

How to give the runtime input in selenium IDE?

I want to get input at runtime using selenium ide. could any one help me?
You can put break command or input-box
1.By input-box
Command 1
Command 2
Command 3
4th command will be
storeEval | prompt(“Enter input”); |variable
type | locator of field where you want to put value| ${variable}
continue with your next commands
2.By break command
Command 1
Command 2
Command 3
4th command will be
Break
Enter input manually and resume execution of test
continue with your next commands
you can use java.util.scanner for entering user input during runtime.
import java.util.Scanner;
public class UserInputExample(){
Scanner inputText = new Scanner(System.in);
public static void main(String[] args ){
String search= inputText.next();
driver.findElement(By.xpath("//body/div[#id='searchform']/form[#id='tsf']/div[2]/div[1]/div[2]/div[1]/div[2]/input[1]")).clear().sendKeys(search);
}
}