I am catching an error when I try to compile the template application from imgui-java library using gradle.
Main.java
import imgui.ImGui;
import imgui.app.Application;
public class Main extends Application {
#Override
protected void configure(Configuration config) {
config.setTitle("Dear ImGui is Awesome!");
}
#Override
public void process() {
ImGui.text("Hello, World!");
}
public static void main(String[] args) {
launch(new Main());
}
}
Error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Failed to dynamically load library: /tmp/lwjglbuwnertys/3.2.3-SNAPSHOT/libglfw.so(error = null)
at org.lwjgl.system.linux.LinuxLibrary.loadLibrary(LinuxLibrary.java:32)
at org.lwjgl.system.linux.LinuxLibrary.<init>(LinuxLibrary.java:19)
at org.lwjgl.system.APIUtil.apiCreateLibrary(APIUtil.java:123)
at org.lwjgl.system.Library.loadNative(Library.java:360)
at org.lwjgl.system.Library.loadNativeFromLibraryPath(Library.java:349)
at org.lwjgl.system.Library.loadNative(Library.java:264)
at org.lwjgl.system.Library.loadNative(Library.java:222)
at org.lwjgl.glfw.GLFW.<clinit>(GLFW.java:674)
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1042)
at java.base/jdk.internal.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
at java.base/jdk.internal.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:186)
at java.base/java.lang.reflect.Field.acquireFieldAccessor(Field.java:1105)
at java.base/java.lang.reflect.Field.getFieldAccessor(Field.java:1086)
at java.base/java.lang.reflect.Field.getInt(Field.java:594)
at org.lwjgl.system.APIUtil.apiClassTokens(APIUtil.java:348)
at org.lwjgl.glfw.GLFWErrorCallback$1.<init>(GLFWErrorCallback.java:98)
at org.lwjgl.glfw.GLFWErrorCallback.createPrint(GLFWErrorCallback.java:97)
at imgui.app.Window.initWindow(Window.java:70)
at imgui.app.Window.init(Window.java:48)
at imgui.app.Application.initialize(Application.java:91)
at imgui.app.Application.launch(Application.java:81)
at Main.main(Main.java:54)
build.gradle:
plugins {
id 'application'
}
repositories {
mavenCentral()
}
dependencies {
testImplementation 'junit:junit:4.13.1'
implementation 'com.google.guava:guava:30.0-jre'
String imgui_java_version = '1.84.1.0'
implementation "io.github.spair:imgui-java-app:$imgui_java_version"
}
application {
mainClass = 'Main'
}
Creater of this library say:
So you only need one dependency line or one jar in classpath to make
everything to work. You don't need to add separate dependencies to
LWJGL or native libraries, since they are already included.
So I can't understand, why do I have a problem? How can I fix it?
It may depend on the version of imgui-java you're using, on how you actually installed it, maybe on your OS...
My advice: have a look at the project issues. Many users seem to have had similar UnsatisfiedLinkError issues.
In case you're not familiar with Java: UnsatisfiedLinkError is the error you get when Java is trying to load some native library to interact with.
In your case, the missing library is /tmp/lwjglbuwnertys/3.2.3-SNAPSHOT/libglfw.so.
Maybe you could check if it is present at this location? Maybe it is present with another name (something like libimgui-java64.so instead)? If it is the case, try to rename the library.
Related
Im having trouble resolving the following runtime error: "Multiple HTTP implementations were found on the classpath. To avoid non-deterministic loading implementations, please explicitly provide an HTTP client via the client builders, set the software.amazon.awssdk.http.service.impl system property with the FQCN of the HTTP service to use as the default, or remove all but one HTTP implementation from the classpath"
I have the following two dependencies in my gradle.build :
implementation 'software.amazon.lambda:powertools-parameters:1.12.3'
implementation 'software.amazon.awssdk:sns:2.15.0'
They both seem to use the default HTTP client and compiler cannot determine which one to use. See below the declaration and use of them in code:
private static SsmClient = SsmClient.builder().region(Region.of((region == null) ? Regions.US_EAST_1.getName() : region)).build();
private static SSMProvider ssmProvider = ParamManager.getSsmProvider(client);
static SnsClient sns = SnsClient.builder().credentialsProvider(DefaultCredentialsProvider.builder().build())
.region((region == null) ? Region.US_EAST_1 : Region.of(region)).build();
I cannot remove one from the class path since I need both for my application and I have not succesfully been able to define an awssdk client via the builders.
I tried this but still got same runtime error:
client = SsmClient.builder().httpClientBuilder(new SdkHttpClient() {
#Override
public void close() {
}
#Override
public ExecutableHttpRequest prepareRequest(HttpExecuteRequest request) {
return null;
}
})
Looks like you will have to exclude one of the versions of http-client in your pom
implementation('<dependency>') {
exclude group: '<group>', module: '<module>'
}
where dependency is one of:
'software.amazon.lambda:powertools-parameters:1.12.3'
'software.amazon.awssdk:sns:2.15.0'
You can run gradle dependencies to see the dependency tree to figure out which one you want to exclude from
I am generating JavaDocs using gradle for my Android Project
task javaDocs(type: Javadoc) {
failOnError false
source = android.sourceSets.main.java.sourceFiles
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.compile
excludes = ['com/example/package1/**', 'com/example/package2**',
'com/example/package3/A\$B*']
}
The problem I am facing is that I need Class A to be present in the JavaDocs but want to ignore nested class B which is nested inside Class A
public class A { // Need to have this in JavaDocs
...
public static final class B { // Need to ignore this from JavaDocs
...
}
}
I am unable to come up with any pattern which can allow me to exclude class B in the gradle script mentioned above. Any help would be really appreciated.
Hi I am working on a Maven project having dependency on a external jar which has a class ConfigLoader having following loader() method.
public class ConfigLoader {
public void initialize() {
loader();
}
private static void loader() {
URL configURL = ConfigLoader.getClass().getResource("runtimeConfiguration.xml");
//some other method calls to which configURL is an argument.
}
//other methods of ConfigLoader class
}
and the directory structure is like this -
src
|...main
|.......java
|.......resources
|................dev
|................prod
both dev and prod have a file named runtimeConfiguration.xml
and the code which uses this class is
public class Application {
private Application application;
public static void main(String []args){
application = new Application();
application.invokeConfigLoader();
//additional code
}
private void invokeConfigLoader() {
configLoader.initialize();
}
}
The error I get is
could not find: runtimeConfiguration.xml
and the exception is thrown at the getResource() line in the class from jar.
I have tried adding the dev folder to classpath but still the same error. I want to run this code from linux terminal, and the command I am giving from trunk directory (where all my exernal jars and resource folder sits after maven build) is -
java -cp /resources/dev/*:configuration-loader.jar
I am using intelliJ 2017.2 and also tried to add the resources/dev folder as module dependency, but I keep on getting the same error. The resources folder is added as a library via project structure settings. I tried to search a lot but have not found any question with this issue. Kindly help me out as I am new to this environment based development.
Thanks!
ConfigLoader.getClass().getResource("runtimeConfiguration.xml"); will try to get runtimeConfiguration.xml from the same package a the ConfigLoader is defined and not from the root of classpath. Try appending / to runtimeConfiguration.xml.
This should work ConfigLoader.getClass().getResource("/runtimeConfiguration.xml"); or ConfigLoader.getClass().getResource("/dev/runtimeConfiguration.xml"); depending how you are adding resources to your classpath.
See javadoc for more.
I'm reading up on Gradle and am very interested in it, specifically because (it appears) that it allows the introduction of inheritance into the build process. For instance, if I have a Java web app that might be packaged and deployed to Google App Engine instances as well as Amazon EC2 instances, I need a sophisticated build that can take the same Java, XML, PROPERTIES, CSS and image files and package/deploy them into 2 drastically-differently packaged WAR files.
GAE apps are very specific as to how they are packaged; EC2 (pretty much) just require that you conform to servlet specs. GAE apps get "deployed" by running an update command from the appcfg.sh script that comes with your SDK; EC2 has their own way to deploy apps. The point is, they are very different packaging/deployment processes for both PaaS providers:
public abstract class PackageTask {
// ...
}
// Package my Eclipse project for deployment to GAE.
public class AppEnginePackageTask extends PackageTask {
// ...
}
// Package my Eclipse project for deployment to EC2 instances.
public class AmazonPackageTask extends PackageTask {
// ...
}
public abstract class DeployTask {
// ...
}
// Deployment to GAE.
public class AppEngineDeployTask extends DeployTask {
// ...
}
// Deployment to EC2.
public class AmazonDeployTask extends DeployTask {
// ...
}
Then, I might have a myapp.gradle buildfile that templates the build order of tasks:
clean()
compile()
package()
deploy()
...and somehow, I can configure/inject AppEnginePackageTask/AppEngineDeployTask in place of package()/deploy() for a GAE-based build, or I can configure/inject AmazonPackageTask/AmazoneDeployTask into those templated tasks. Again, I'm not sure how to do this (or even if Gradle can do this), but it's what I'm after.
My understanding was that Gradle can do this. Ant can also be forced to have highly-modular, elegant builds that work this way, but being XML-based, it takes some finessing, whereas an OOP-based language like Groovy makes this cleaner and simpler.
However, all the examples I see of Gradle tasks take the following form:
task package(dependsOn: 'compile') {
// ...
}
task deploy(dependsOn: 'package') {
// ...
}
So I ask: these look/feel like non-OOP task definitions. Is my understanding of Gradle (and its OOP nature) fundamentally incorrect? What am I missing here? How can I accomplish these notions of "configurable/injectable build templates" and inheritance-based tasks? Thanks in advance!
Edit I re-tagged this question with "groovy" because Gradle buildscripts are written in a Groovy DSL, and someone who happens to be a Groovy-guru (say that 5 times fast) might also be able to chime in even if they know little about Gradle.
As described here, there are simple tasks and enhanced tasks. The latter are much more flexible and powerful.
The following example isn't exactly what you describe, re:injection, but it illustrates OOP.
Here is the sample build.gradle file. It avoids "package" as that is a keyword in Java/Groovy. The 'build' target depends on 'compile' and some flavour of 'doPack', depending on a property called 'pkgTarget'.
task compile << {
println "compiling..."
}
task build() << {
}
build.dependsOn {
compile
}
build.dependsOn {
if (pkgTarget == "Amazon") {
task doPack(type: AmazonPackageTask)
} else if (pkgTarget == "Google") {
task doPack(type: GooglePackageTask)
} else {
task doPack(type: MyPackageTask)
}
}
where the tasks are defined later in the same file. (Per doc, this code can go into a "build src" directory):
// -----
class MyPackageTask extends DefaultTask {
def init() { println 'common stuff' }
#TaskAction
def doPackage() {
println 'hello from MyPackageTask'
}
}
class AmazonPackageTask extends MyPackageTask {
#TaskAction
def doPackage() {
init()
println 'hello from AmazonPackageTask'
}
}
class GooglePackageTask extends MyPackageTask {
#TaskAction
def doPackage() {
init()
println 'hello from GooglePackageTask'
}
}
and here is the gradle.properties file:
pkgTarget=Amazon
I'm evaluating Scala on Android by starting with the NotesList demo. I was able to replace the NotesLiveFolder.java file with its Scala equivalent without problem.
Next, I introduced Roboguice, creating a simple NotesListApplication.java that sets up the Guice modules, and successfully injected a resource into the NoteEditor.java activity.
Finally, I when I tried to replace NotesListApplication.java with its Scala equivalent, I get the following runtime error before the application finishes booting:
java.lang.ClassNotFoundException: com.example.android.notepad.NotesListApplication in loader dalvik.system.PathClassLoader[/data/app/com.example.android.notepad-1.apk]
I created a Google Code project containing the complete Eclipse project and source. The original functioning NotesListApplication.java is:
package com.example.android.notepad;
import java.util.List;
import roboguice.application.RoboApplication;
import com.google.inject.Module;
public class NotesListApplication extends RoboApplication {
private Module module = new BindEverything();
public void setModule(Module module) {
this.module = module;
}
#Override
protected void addApplicationModules(List<Module> modules) {
modules.add(module);
}
}
and the Scala equivalent that causes the error is:
package com.example.android.notepad
import roboguice.application.RoboApplication
class NotesListApplication extends RoboApplication {
val module : Module = new BindEverything()
override protected def addApplicationModules(modules:java.util.List[Module] ) {
modules.add(module)
}
}
I'm building in Eclipse with the ScalaIDE plugin. I'm not running any treeshaker/proguard/etc.
The disassembly shows the Scala classes as expected:
Class descriptor : 'Lcom/example/android/notepad/NotesLiveFolder;'
...
Class descriptor : 'Lcom/example/android/notepad/NotesListApplication;'
Any ideas what could cause this?
Upgrade to 2.0-SNAPSHOT of RoboGuice and then you dont have to use RoboApplication and it all binds automatically. For more how to bind check out the slides from Mike Burtons presentations about RoboGuice at AnDevCon 2 and check out the 2.0 section on the wiki.
Like I posted on the mailing list maybe check out the apk with dedexer and see if the class was actually removed e.g. by Proguard or renamed so it cant be found as a next step.