Team,
Ia m using IKVM to convert a jar file to a dll, so that I can use it with C# to test the Java application...I dont have the original java source code or the class files.
Here is what I am doing and the error I get:
ikvmc myApplication.jar
Note IKVMC0002: output file is "asapi.dll"
Warning IKVMC0100: class "org.apache.log4j.Logger" not found
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in "com.myApp.authenticateUser(LNote IKVMC0002: output file is "asapi.dll"
Warning IKVMC0100: class "org.apache.log4j.Logger" not found
Warning IKVMC0111: emitted java.lang.NoClassDefFoundError in
vices.AsApi.authenticateWithArtifact(Ljava.lang.String;Lcom.myApp.AppApi)....
Any ideas? This jar file doesnt contain a main method...
Regards,
Deekshit
I believe you need something more along the lines of:
/usr/bin/mono \
/path/to/ikvm-0.42.0.6/bin/ikvmc.exe \
/path/to/project/target/project-1.2.3.4.jar \
-out:/path/to/project/target/project-1.2.3.4.dll \
-keyfile:/path/to/project/target/private-key.snk \
-assembly:project-1.2.3.4 \
-fileversion:1.2.3.4 \
-version:1.2.3.4
If your application depends on third-party jars, you might need to add them to the jar, using shading (not good practice at all).
Related
I'm trying to cross-compile the JNI Bridge Jlibfprint using buildroot.
This is the source code.
Here is the .mk file:
JLIBFPRINT_VERSION = 775295f08174d11d39da9e327120b128ef270fc4
JLIBFPRINT_SITE = $(call github,eduardobogoni,jlibfprint,$(JLIBFPRINT_VERSION))
JLIBFPRINT_AUTORECONF = YES
JLIBFPRINT_SUBDIR = JlibFprint_jni
#JLIBFPRINT_CONF_OPTS = --enable-debug-log --enable-udev-rules=no --disable-debug-log
JLIBFPRINT_INSTALL_STAGING = YES
define PREPARE_FILES_AND_FIX_DIRECTORY
cd $(#D)/JlibFprint_jni && \
libtoolize
endef
JLIBFPRINT_PRE_CONFIGURE_HOOKS += PREPARE_FILES_AND_FIX_DIRECTORY
$(eval $(autotools-package))
Extract, Patch, Update, Configure, Autoreconfiguring, Patching libtool run without problem.
Then it failed at Building stage with this:
libfprint_jni_la-jlibfprint_JlibFprint.o
In file included from jlibfprint_Device.cpp:1:0:
jlibfprint_Device.h:5:10: fatal error: jni.h: No such file or directory
#include <jni.h>
^~~~~~~
compilation terminated.
Then I added, these includes to the /JlibFprint_jni/src/Makefile.am
ADD_INCLUDES=-I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/mariano/buildroot/output/build/libfprint-0.7.0 -I/home/mariano/buildroot/output/build/libfprint-0.7.0/libfprint/nbis/include
And now it fails with:
arm-linux-gnueabihf-g++: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/lib/jvm/java-11-openjdk-amd64/include'
arm-linux-gnueabihf-g++: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/lib/jvm/java-11-openjdk-amd64/include'
libtool: compile: /home/mariano/buildroot/output/host/bin/arm-linux-gnueabihf-g++ -DPACKAGE_NAME=\"libfprint_jni\" -DPACKAGE_TARNAME=\"libfprint_jni\" -DPACKAGE_VERSION=\"1.0\" "-DPACKAGE_STRING=\"libfprint_jni 1.0\"" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"libfprint_jni\" -DVERSION=\"1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_STRING=1 -DHAVE_IOSTREAM=1 -DHAVE_LIBFPRINT_FPRINT_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -I. -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/lib/jvm/java-11-openjdk-amd64/include -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux -I/home/mariano/buildroot/output/build/libfprint-0.7.0 -I/home/mariano/buildroot/output/build/libfprint-0.7.0/libfprint/nbis/include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -c jlibfprint_JlibFprint.cpp -fPIC -DPIC -o .libs/libfprint_jni_la-jlibfprint_JlibFprint.o
Makefile:496: recipe for target 'libfprint_jni_la-jlibfprint_Device.lo' failed
Jlibfprint requires a JDK, but Buildroot doesn't have a JDK package. Therefore, building Jlibfprint using Buildroot will never work.
I downloaded JDK for ARM 32 bits and addded the includes into that folder.
I removed the BR2_COMPILER_PARANOID_UNSAFE_PATH=n as Arnout said it was wrong. And it cross-compiled without issues.
I ran the Sample Run and it worked with an Upek fingerprint scanner.
I am working on this now. Buildroot includes openjdk, but does not install the jni header files, so when using staging as sysroot for cross compilation, things go wrong.
As far as I can tell the jni headers (jni.h and jni_md.h) serve as type translations only and can be included without problem for the target. I added them to the sysroot and compiling works without issues.
How can I ask UMLGraph to generate a single diagram for all the underlying .java classes within a package ?
I am using UMLGraph along with Graphviz to generate a .png UML diagram file.
The command that I am running to geenrate a.dot file is :
java -jar C:/Program Files/Java/jdk1.7.0_80/lib/UmlGraph.jar -all -private A.java
This runs succesfully to geenrate a .dot file.
However,I wish to create a single UML diagram out of them ( They are all linked to eachother via java code).
The "uml-parser-test-1" (folder/package) contains all about 5 .java files and for that I am running
C:/Users/xyz > java -jar "C:/Program Files/Java/jdk1.8.0_60/lib/UmlGraph.jar" -all -private "D:/xyz/abcd/uml-parser-test-1/"
When I run above code , I get an error : UMLGRAPH ERROR - ILLEGAL PACKAGE NAME
Where am I going wrong
**EDIT:: 6th Oct**
There was an issue with umlgraph.jar path and I had corrected it. Thanks for pointing that out.
Now I am able to run the command you suggested without any errors. THe thing is my "Persons" package(folder) contains 4 java files(A,B,C,D.java). When I run the command, it generated .dot file on the command line and not in my file system.Moreover, it is incomplete as there is no information about classes :
Below is the trace of my command line .
C:\Users\xyz>java -classpath "C:/Program Files/Java/jdk1.8.0_60/lib/UmlGraph.jar;C:/Program Files/Java/jdk1.8.0_20/lib/tools.jar" org.umlgraph.doclet.UmlGraph -package -output - -sourcepath "C:/Program Files/Java/jdk1.8.0_60/lib/Persons" org.umlgraph.doclet
Loading source files for package org.umlgraph.doclet...
UmlGraph: warning - No source files for package org.umlgraph.doclet
Constructing Javadoc information...
UmlGraph: warning - No source files for package org.umlgraph.doclet
UMLGraph doclet version R5_7_2-3-gee82a7 started
Building general class diagram
#!/usr/local/bin/dot
#
# Class diagram
# Generated by UMLGraph version R5_7_2-3-gee82a7 (http://www.umlgraph.org/)
#
digraph G {
edge [fontname="arial",fontsize=10,labelfontname="arial",labelfontsize=10];
node [fontname="arial",fontsize=10,shape=plaintext];
nodesep=0.25;
ranksep=0.5;
}
2 warnings
Any idea, why it is not parsing the class details?
You must specify in the command line invocation the package name and the directory where its source code is located. The following example, when run in the UMLGraph directory, generates a diagram for the UMLGraph classes.
java -classpath "lib/UmlGraph.jar;C:\Program Files\Java\jdk1.8.0_20/lib/tools.jar" org.umlgraph.doclet.UmlGraph -package -output - -sourcepath src/main/java org.umlgraph.doclet | dot -Tpng -oumlgraph.png
I want to run a java project in terminal. When I compiled, no error occurred, but when I run the program I get the following error:
Could not find or load main class orException in thread "main"
java.lang.NoClassDefFoundError: Appium (wrong name:
com/appiumproj/test/Appium)
Please help me to solve this problem.
iMac:~ Samuel$ javac -cp /Users/Samuel/Downloads/AppiumTest/lib/selenium-server-standalone-2.45.0.jar:/Users/Samuel/Downloads/AppiumTest/lib/gson-2.3.1.jar:/Users/Samuel/Downloads/AppiumTest/lib/java-client-2.2.0.jar: /Users/Samuel/Downloads/AppiumTest/src/com/appiumproj/test/Appium.java
iMac:~ Samuel$ java -cp /Users/Samuel/Downloads/AppiumTest/lib/selenium-server-standalone-2.45.0.jar:/Users/Samuel/Downloads/AppiumTest/lib/gson-2.3.1.jar:/Users/Samuel/Downloads/AppiumTest/lib/java-client-2.2.0.jar: /Users/Samuel/Downloads/AppiumTest/src/com/appiumproj/test/Appium
Error: Could not find or load main class .Users.Samuel.Downloads.AppiumTest.src.com.appiumproj.test.Appium
iMac:~ Samuel$
You need to specify the name of the class - not a filename. It needs to be the fully-qualified class name, and it needs to be on the classpath. So after compiling, you'd want something like this (just spread out on multiple lines for readability; the backslashes are line continuations - you should be able to copy and paste this straight into your shell):
java -cp /Users/Samuel/Downloads/AppiumTest/lib/selenium-server-standalone-2.45.0.jar\
:/Users/Samuel/Downloads/AppiumTest/lib/gson-2.3.1.jar\
:/Users/Samuel/Downloads/AppiumTest/lib/java-client-2.2.0.jar\
:/Users/Samuel/Downloads/AppiumTest/src \
com.appiumproj.test.Appium
Are you sure your compiled version is in /Users/Samuel/Downloads/AppiumTest/src/com/appiumproj/test/ ? I would say that it is probably where the javac was run. Check and find it and specify the path to to compile version
I am trying to use randoop(automatic test generator for Java) and randoop cannot find my class:
eliezer#ubuntu:~/Desktop$ java -ea -classpath \
randoop.1.3.2.jar:home/eliezer/myclasses \
randoop.main.Main gentests \
--testclass=/home/eliezer/Desktop/myclasses/ArrayListError
policy = sun.security.provider.PolicyFile#85af80
Throwable thrown while handling command:java.lang.Error:\
classForName(/home/eliezer/Desktop/myclasses/ArrayListError)
java.lang.Error: classForName(/home/eliezer/Desktop/myclasses/ArrayListError)
at randoop.util.Reflection.classForName(Reflection.java:206)
at randoop.util.Reflection.loadClassesFromList(Reflection.java:386)
at randoop.main.GenInputsAbstract.findClassesFromArgs(GenInputsAbstract.java:507)
at randoop.main.GenTests.handle(GenTests.java:184)
at randoop.main.Main.nonStaticMain(Main.java:80)
at randoop.main.Main.main(Main.java:42)
Caused by: java.lang.ClassNotFoundException: \
/home/eliezer/Desktop/myclasses/ArrayListError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at randoop.util.Reflection.classForName(Reflection.java:198)
... 5 more
Randoop failed.
Last sequence under execution:null
My class is called ArrayListError.java and is found in /home/eliezer/Desktop/myclasses.
The randoop docs are found at: https://randoop.github.io/randoop/manual/index.html.
I am sure it is something really trivial but I'm inexperienced with these things.
You need to set your classpath such that, jvm should be able to locate all your resources like classes, files, jars etc.
In your case, ArrayListError is placed under directory /home/eliezer/Desktop/myclasses. You need to place this in your classpath.
Once you point your classpath to mentioned directory, You need to pass the class name to --testclass=ArrayListError.
java -ea -classpath randoop.1.3.2.jar:/home/eliezer/Desktop/myclasses randoop.main.Main gentests --testclass=ArrayListError
should fix your problem. I suggest you to search on setting classpath and read on.
This is wrong
my class is called ArrayListError.java and is found in
/home/eliezer/Desktop/myclasses.
Your ArrayListError.java is the source code, but java virtual machine needs a compiled class in its classpath.
EDIT:
Since you said that you have the .class file also, then your problem can be solved in two ways
a. No package
Run the command (take care of the --testclas, it is not directory, it should be the class)
java -ea -classpath randoop.1.3.2.jar:/home/eliezer/myclasses
randoop.main.Main gentests --testclass=ArrayListError
b. Class in a package
If your ArrayListError does have package com.test; make a directory /com/test in your myclasses directory and run the command below
java -ea -classpath
randoop.1.3.2.jar:/home/eliezer/myclasses/com/test/ randoop.main.Main
gentests --testclass=com.test.ArrayListError
Check your classpath on the command line;
I see home/eliezer/myclasses, without the leading /.
I get the following error:
org.dbpedia.spotlight.exceptions.ConfigurationException: Cannot find spotter file ../dist/src/deb/control/data/usr/share/dbpedia-spotlight/spotter.dict
at org.dbpedia.spotlight.model.SpotterConfiguration.<init>(SpotterConfiguration.java:54)
at org.dbpedia.spotlight.model.SpotlightConfiguration.<init>(SpotlightConfiguration.java:143)
at org.dbpedia.spotlight.web.rest.Server.main(Server.java:70)
Usage:
java -jar dbpedia-spotlight.jar org.dbpedia.spotlight.web.rest.Server [config file]
or:
mvn scala:run "-DaddArgs=[config file]"
Quick solution:
wget http://spotlight.dbpedia.org/download/release-0.5/dbpedia-spotlight-quickstart.zip
unzip dbpedia-spotlight-quickstart.zip
cd dbpedia-spotlight-quickstart/
./run.sh
Explanation:
DBpedia Spotlight looks for ~3.5M things of ~320 types in text and tries to disambiguate them to their global unique identifiers in DBpedia. Therefore it needs data files to accompany its jar. A minuscule example is distributed along with the source, but for real use cases you may need the larger files. After you've downloaded the files, you need to modify the configuration in server.properties with the correct path to the files. The error message you got tells you that one of the necessary files (spotter.dict) could not be found in the path you indicated in your server.properties.
More information available here:
https://github.com/dbpedia-spotlight/dbpedia-spotlight/wiki/Run-from-a-JAR