MouseInfo getLocation causes JVM crash in java? - java

I'm attempting to run the following program:
package test;
import java.awt.*;
public class Main {
public static void main(String[] args) {
System.out.println(MouseInfo.getPointerInfo().getLocation().x + "," + MouseInfo.getPointerInfo().getLocation().y);
}
}
However, after running it in IntelliJ, the program will just sit there for about 10 seconds and then exit with this:
Process finished with exit code -1073740791 (0xC0000409)
Most of the google results (and stack overflow posts) related to this error seem to think it is an NVIDIA driver issue, but those posts also state that an updated driver with a fix was posted in February and the driver on my computer is version 382, which is a newer version than the fix posted, so it would have included that fix.
Any ideas how to resolve this issue?

Related

How to get Lightrun running in IntelliJ IDEA 2022.3.1?

No matter what I do Lightrun will generate the following error message:
General agent error at jvm_internals.cc:186.
This is my first time using Lightrun.
This is my code:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println(new Scanner(System.in).nextInt() + new Scanner(System.in).nextInt());
}
}
The code itself runs perfectly.
I am using IntelliJ IDEA 2022.3.1.
LR doesn’t work on this version. A bit buggy on the ij versions for the past 2 months…

Can't get OpenCV to work with Java+Maven+IntelliJ

I've seen lots of people asking similar questions to mine but their solutions aren't working for me. Here's what I've got:
I downloaded the latest OpenCV for Windows (2.4.9). I extracted this to C:\opencv-249
I then created a new Maven 3 project in IntelliJ. This works fine and I can run the compile/package goals, etc. I can execute and debug my program. This is all good.
Next, I tried to pull OpenCV into my test app and ended up with the following code:
package com.foo.OpenCVTest;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.CvType;
/**
* Created by rick on 5/7/2014.
*/
public class RobotCntrl {
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
static public void main(String args[]) {
System.out.println("In main!");
System.out.println("Core Lib: " + Core.NATIVE_LIBRARY_NAME);
Mat m = Mat.eye(3, 3, CvType.CV_8UC1);
System.out.println("m = " + m.dump());
}
}
I then added the local OpenCV to my pom.xml:
<dependency>
<groupId>org.opencv</groupId>
<artifactId>opencv</artifactId>
<version>2.4.9</version>
<systemPath>${java.home}/../../../../opencv-249/build/java/opencv-249.jar</systemPath>
<scope>system</scope>
</dependency>
And I added OpenCV as a project library:
And I modified the IntelliJ VM Options (Edit Configurations) to update the java.library.path to point to the OpenCV dlls:
When I run the application appears to load the opencv_java249.dll library just fine (it doesn't complain), but for the line:
Mat m = Mat.eye(3, 3, CvType.CV_8UC1);
It bombs out complaining that it can't find the underlying n_eye() native function:
In main!
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J
Core Lib: opencv_java249
at org.opencv.core.Mat.n_eye(Native Method)
at org.opencv.core.Mat.eye(Mat.java:1467)
at com.aether.Robots.RobotCntrl.main(RobotCntrl.java:25)
Process finished with exit code 1
I'm at a loss now. It's loading the wrapper library but it can't call the dependent functions. For the previous questions on similar issues, it tends to be resolved when people update their java.library.path variable, but mine seems correct:
-Djava.library.path=C:\opencv-249\build\x64\vc10\bin;C:\opencv-249\build\java\x64
or people forget to call System.loadLibrary(), but that call is succeeding (as far as I can tell) for me.
Any ideas?

Java Vuser on LoadRunner 11.52 not working

Recently I have started testing of some application which are Java based. Now the problem is even if I put a simple statement lik;
lr.output_message("Hello");
nothihng is coming up. I havw already set the classpath and jdk path, no error is coming while compilation but during run time no display is coming up.
Sample Script
import lrapi.lr;
import lrapi.web;
public class Actions
{
public int init() throws Throwable
{
return 0;
}//end of init
public int action() throws Throwable
{
lr.start_transaction("trans1");
System.out.println("Lin 1");
lr.output_message("Error");
lr.message("Pulkit");
lr.end_transaction("trans1",lr.AUTO);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
......................
Actually by doing some R&D the same code is working on 9.52 but not on 11.52 so is it a bug?? can anyone suggest me?
I have another hypothesis. Since you have switched versions the environment is not yet set correctly for 11.52, but it is for 9.52. This could be due to many things, such as installing a 64 bit edition of Java on your 11.52 box and a 32 bit edition on your 9.52 box and then expecting the same results. Perhaps even installing an unsupported version of Java under 11.52, but a supported version under 9.52. Start scoping the differences. Document them well for you will have to take the same setup to your 11.52 load generators for reproduction there.

Changing the color of output

I was trying to change the color of console output in java.As my program output displays a warning message so i thought to change that warning color.
After searching it over stackoverflow and response for similar questions I came accross Jansi and JLibs but they are not working.This is the sample code which i wrote using jansi.I included the jar in class-path
import static org.fusesource.jansi.Ansi.*;
import static org.fusesource.jansi.Ansi.Color.*;
class Test
{
public static void main(String[] args)
{
System.out.println( ansi().eraseScreen().fg(RED).a("Hello").fg(GREEN).a(" World").reset());
}
}
However its doing nothing just printing this: ←[2J←[31mHello←[32m World←[m
I am using windows 7 and jdk 1.7 and i am not using eclipse.
Any help
from Jansi
Using jansi is easy. Before you start sending ANSI escape sequences to
System.out make sure you run: AnsiConsole.systemInstall();

OpenGL in Java on Netbeans: NoClassDefFoundError

I am on a Mac running Netbeans 6.9.
I downloaded and installed LWJGL using this tutorial down to the letter:
http://lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_NetBeans
I finished the installation and copied sample code to see if my system is working. I got a bug, and was not sure if it was because of faulty code or I was doing something wrong. So I shortened down the code to this little simple bit:
package javaopengl;
import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;
//Testing
public class Main {
public static void main(String[] args) {
boolean fullscreen = (args.length == 1 && args[0].equals("-fullscreen"));
try {
Display.create();
Display.destroy();
} catch (Exception e) {
e.printStackTrace(System.err);
}
System.exit(0);
}
}
But I still get the same error:
run:
Exception in thread "main" java.lang.NoClassDefFoundError: =
Caused by: java.lang.ClassNotFoundException: =
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
I am not sure what exactly is going on, Would you please tell me what is going on and how to fix it?
Note: When i am looking at the text in the development environment, it does not show those red lines indicating there are any errors.
What are you typing (or what is netbeans running) to run this? Since the Mac filesystem is fairly case-agnostic unless you've specified otherwise, running java javaopengl.main will look for a file main.java, which is there (Main.java will be returned). But the class is Main, and you can get this exception from the difference. If this is being run from an ant script, I suggest making sure you have the correct capitalization (the class should be javaopengl.Main). A simple way to test this is to delete everything except the class definition and an empty public static void main(String[] args) {}
Alternatively, you could have something simpler, like your classpath out of whack. Missing the lwjgl jar would get you there, but if you followed the directions in that tutorial, that actually seems less likely. Still, you can test this.
package javaopengl;
public class Main {
public static void main(String[] args) {
System.out.println("well, main works");
Class checkjar = Class.forName("org.lwjgl.opengl.Display");
System.out.println("My ClassLoader found: " + checkjar.getCanonicalName());
}
}
Also, remove import org.lwjgl.Sys; from your shortened example. It doesn't appear to be needed, provided it isn't the source of your problems :).

Categories

Resources