I'm trying to build the neo4j GetAll plugin. Project contains only one example class from here.
When I try to run curl http://localhost:7474/db/data/ext/GetAll/graphdb/get_all_nodes, I get the error message:
No such ServerPlugin exception
I'm using neo4j-community-2.2.1 (on Windows) and jdk1.7.0_79.
My project consists of :
GetAll.java in org.neo4j.examples.server.plugins package
META-INF/services/org.neo4j.server.plugins.ServerPlugin file with this content: org.neo4j.examples.server.plugins.GetAll
in buildpath are all jars from %NEO4J_HOME%\lib included.
The jar-file is built using jar -cvf myext.jar * and than that jar placed in %NEO4J_HOME%\plugins.
I have no idea, why I cannot make it work properly. Any suggestions?
The screenshot clearly shows that GetAll.class is located in directory bin/org/neo4j/examples/server/plugins instead of org/neo4j/examples/server/plugins (get rid of the bin).
Related
I try to create a Minecraft Plugin (it's my first one) and I can't fix this error:
So, the plugin compiles good but when the code has to execute this code :
BCrypt.checkpw(mdp, result.getString("mdp"))
that come from the lib org.mindrot.BCrypt, I have this error :
Caused by: java.lang.NoClassDefFoundError: org/mindrot/BCrypt
But, when I open my JAR with WinRAR, there is my lib bcrypt (so it's well export). And it's also in my .classpath.
Can you help me ?
Thanks.
There are several ways to configure the CLASSPATH when launching a java application via the java command. According to what you posted so far, I would use the -classpath flag:
java -classpath spigot.jar;jbcrypt.jar class.containing.main.method.MyMain
Alternatively, you could modify the MANIFEST in file spigot.jar. Refer to Adding Classes to the JAR File's Classpath.
Or you could copy jbcrypt.jar to the directory pointed to by the java System property "java.ext.dirs".
Both class.getResource(FILE_NAME) and class.getClass().getClassLoader().getResource(FILE_NAME) run perfectly inside my eclipse but the same code getting failed to locate the file which is inside the jar file, when run as an executable jar in windows machine.
I have gone through all related links available for this problem (well, not exactly the same issue but 90% in sync), asked for solution but no reply came from any of those posts, so I'm posting my issue as a separate question hoping for help on this.
In total, 4 cases I have ran to resolve but none worked so far and I'm out of ideas now.
class.getClass().getClassLoader().getResource("/resources/readme.txt");
class.getResource("/resources/readme.txt");
class.getClass().getClassLoader().getResource("resources/readme.txt");
class.getResource("resources/readme.txt");
Ouf of all the above 4 cases, only 2 cases ran successfully in eclipse which are as mentioned below.
class.getResource("/resources/readme.txt");
class.getClass().getClassLoader().getResource("resources/readme.txt");
The other 2 cases just throwing me Exception in thread "main" java.lang.NullPointerException
Coming to the executable jar, all 4 cases are throwing me the Exception in thread "main" java.lang.NullPointerException.
So I have created a folder named resources where my jar is residing and placed my files inside this folder and ran the jar. Now the jar is running without any issues referring to the files inside the resources folder I created. So wherever I run this jar (windows, linux etc.,) I need to create a resources folder and place my files under the folder. Now the question is, can it be possible to make my jar refer the resources folder which is inside the jar itself?
Any help on this is much appreciated!
To get your txt file:
File yourFileIsHere = new File("resources/readme.txt");
Where put your file?
In the same location of your jar, example:
myapp/yourjar.jar
myapp/resources/readme.txt
If you want read file inside of your "src" folder:
InputStream yourInputStream = new YourClass().getClass().getClassLoader().getResourceAsStream("readme.txt");
If you are using Spring:
org.springframework.util.ResourceUtils.getFile("classpath:readme.txt")
Otherwise:
import com.google.common.io.Resources
byte[] byteSource = Resources.asByteSource(Resources.getResource("readme.txt")).read()
method class.getClass().getClassLoader().getResource() may take 3 prefixes: url:, classpath: and file: each prefix tells what is your base of search. If you want to search inside your jar use classpath: prefix. That tells your classloader to search everywhere within your classpath. Here is one example how to deal with it with Spring tools. Look also at ResourceLoader class in Spring
I have a play framework (2.2.3) project which also uses maven. One of the dependencies in my project is org.apache.wss4j.wss4j-ws-security-common-2.1.4.jar. This JAR has a messages folder in classpath. On starting play I get the following error (I am just pasting a few lines here)
Oops, cannot start the server.
MainException: class java.lang.NullPointerException(null)
class java.lang.NullPointerException(null)
java.io.FilterInputStream.read(FilterInputStream.java:133)
play.api.i18n.Messages$MessagesParser.parse(Messages.scala:216)
If I remove the messages folder from this JAR, play starts normally. I assume that Play tries to load all messages in the classpath and expects them to be files - it breaks because the messages in the WSS4J jar is a folder.
How can I resolve this error?
The way I solved this problem was changing the name to the folder that contains the "wss4j_errors.properties" file.
In code, edit line 42 at src/main/java/org/apache/wss4j/common/crypto/WSS4JResourceBundle.java
Run the tests, compile and try the new jar.
Not the answer I would like, but it works.
Hi Guys I have included the Webcam-Capture API in my project.
When I run it in Netbeans everything works fine. But when i compile everything to a runnable jar i get this message trying to run it by cmd line.
can anyone of you help me?
i already tried to unbound and rebound all jars and changing jdks but its not working
add -classpath flag in the command line ,pointing to the path where Webcam-Capture API exists in your file system, unless you want to create a single package executable.In your case It should be something like below
java -classpath YOURJAR.jar;folder_of_dependant_jar/*;. com.awesome.pagackage.Starter
Where YOURJAR.jar contains the com.awesome.pagackage.Starter.main(String args[])
You also mentioned that your jar is a runnable jar it also means that while exporting/building you can do one of the following way.( NOTE , this feature is in eclipse , but you would get the idea ).Each of the following options you see in the library handling does specific things.
The first option: Extracts the dependent jar into your target jar as java packaging.This means if your package is com.awesome.package and the dependent jar has package logic.package; , after the runnable jar is build you could find both these package exists in your jar file.
The second option: I think it is more on eclipse specific since eclipse adds few classes of its own , of runnable generation, so I am not explaining it here.
The third option : is the most interesting one. it creates folder stucture like below
ndon_lib\external.jar ( external jar file )
ndon.jar ( your jar file )
This time the manifest.mf file contains something like below.
Class-Path: . ndon_lib/external.jar
Main-Class: com.awesome.pagackage.Starter
You should set the classpath
java -cp "your.jar" "yourclass"
In Eclipse Indigo (on Mac OSX), I have a project 'Test'. In this project I have a package 'test1'. In this package, I have a class Test.java.
In short the file structure is: Test/src/Test.java and
Test/bin/Test.class
I have a library mylib.jar in lib folder.
I also have a data file named info.dat. In info.dat, there's information about which class to load. For example, in info.dat, I specified: class=Test
then, when I run:
$ java -jar lib/mylib.jar info.dat
(NOTE: this works if I run this command in terminal and have class file in the same folder with info.dat)
the main function in mylib.jar will load Test.class.
I'm using External Tools to achieve this. Here is my External tool setup:
Location: /usr/bin/java
Working Location: /path/to/Test_folder
Argument: -cp . -jar lib/mylib.jar bin/test1/info.dat
However, when I try to run, I get this error:
LOADING INFO FROM FILE bin/test1/info.dat
=> Current directory=[not include because not important]
=> Full pathname=[not include because not important]
java.lang.ClassNotFoundException: Test
I also tried to change class=test.Test in info.dat but got a similar error
java.lang.ClassNotFoundException: test1.Test
The result shows that the info.dat was loaded ok, but the path to class file was not correct. How should I configure the external tool to do what I need? Can someone please give me some instruction?
Many thanks,
It was an easy solution with Run Configuration. I just need to pick the main class from mylib.jar in Java Application and put info.dat in the argument field.
Sorry for wasting the resource here.