When I run the following command:
bin/tdbloader2 --loc=/store/data/here /seed/data/serverfault-dump.nt
And the response I get is:
10:52:31 -- TDB Bulk Loader Start
10:52:31 Data phase
Error: Could not find or load main class com.hp.hpl.jena.tdb.store.bulkloader2.CmdNodeTableBuilder
Which is most likely caused by a problem with my environment variables, somewhere, of something. The problem is, I don't often work with Java and so I don't know enough to know how to figure out what that class cannot be found.
How do make tdbloader2 find the appropriate class?
I had forgotten to set the JENAROOT path variable.
https://jena.apache.org/documentation/tools/
An environment variable JENAROOT is used by all the command line tools to
configure the class path automatically for you. You can set this up as follows:
On Linux / Mac
export JENAROOT=the directory you downloaded Jena to export
PATH=$PATH:$JENAROOT/bin On Windows
SET JENAROOT=the directory you downloaded Jena to SET
PATH=%PATH%;%JENAROOT%\bat
At a minimum you need to set the TDBROOT environment variable to the directory containing your TDB download. This will be the directory above bin as some of the scripts use ${TDBROOT}/bin/foo to launch other scripts
The script attempts to automatically construct a valid class path by calling the tdb_path script which calls either make_classpath_mvn or make_classpath depending on your environment. If you run the tdb_path script directly you can see if it generates a sane looking class path or not (or add what it does generate to your question if the output doesn't provide anything helpful).
Related
PROBLEM: Hello everyone! I have created a Maven project in which i am building
a RESTful API, now i have created few .json files in which i want
to store my JSON data in src/main/resources , but as i can see
every time i make a change ( example: register a user - write in a
file ) all changes get lost whenever i redeploy the WAR file or the
server gets restarted/reloaded.
Can someone please tell me how to use system PATH variable to fix
my problem? I want to store files somewhere i will be able to update
them without having to worry if server is being reloaded or not. Thank you in advance!
SMART WAY, with java configuration and classpath (unix example, launch your application this way)
java -classpath $PATH <your-class-name>
or
setenv CLASSPATH = $PATH
see unix and windows instructions.
BAD WAY, within application code
You can read the PATH variable from the OS environment calling System.getenv() and then looking for the "PATH" elements within the returned map.
Then you have to parse the string (e.g. with StringTokenizer) obtained to get each folder within the PATH variable
you have to look for your JSON files in each of the folder from previous point
I currently wrote a simple GUI in Eclipse which runs as intended. I was hoping to export it so I can share it with my friend (who doesn't need to install eclipse and the java libraries). I tried all 3 library handling method Eclipse provides and none of them works. I read a little online and saw something about a manifest file, but wasn't quite sure what to do with it. Is it going to help?
This is where I placed the folder that comes with the .dll file.
This is the result. Am I doing something wrong?
As indicated by the error messages in the first screenshot, what you are missing here is the native library - the software library written and compiled to native code specific to the operating system. What you will need to do is provide the libraries specific to the operating system on which your software will run, eg. dlls for 32 or 64 bit Windows. The manifest does not provide the capability to include those libraries.
When the program is run on Windows, Java will look for native libraries in the following locations:
The current directory
The directories in the PATH environment variable
The directories in java.library.path (if it's specified)
It may be easiest to simply put all files in the one directory. If you do this, you should be able to run the program in the same way as you do now.
The java.library.path option is only needed if you want to put your native library files in a directory separate to the one in which you run your program and not on your PATH. It is only in this case that you will need to add java.library.path, eg. by adding -Djava.library.path=c:\path\to\your\lib after java. Also note that you may use a relative path, ie. a path that is relative to the directory you are in when you execute the command.
I also see from your later error messages that you have another dependency, but on a java library LeapJava.jar. As running a jar with -jar will only work if you have a single jar, but because you have more than one (your own program plus the dependency), you'll instead need to use the -classpath (or -cp for short) argument and add your main class. The classpath argument is a semicolon-separated list of classpath locations, while the main class is the one containing your public static void main method, eg. your.package.name.YourMainClass. So assuming your UI.jar is still in C:\Users\Ian\Desktop\Leap Data UI, you should be able to navigate to that directory and execute with:
java -cp UI.jar;UI_lib\LeapJava.jar -Djava.library.path="UI_lib\x64" your.package.name.YourMainClass
I'm a little confused by this error. I'm new to Java and the error seems pretty self explanatory, but I've checked my paths (even defined my own) and it still fails to find this library. Is there something I'm doing wrong? See directory screenshot and error screenshot below:
UPDATE
UPDATE 2
If I create a new NetBeans project this works fine. Same code and everything. If I create new IntelliJ project I get this error above. I must be missing something in IntelliJ
UPDATE 3
Found the solution. Adding dependencies is a bit different in IntelliJ. Thanks all for the help.
http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html
Obidisc4j is a .jar file. You just dont see its extension in the explorer.
Regular jar files are not loaded by System.loadLibrary. They are automatically loaded by the JVM's classLoader.
You are using a native library. It doen't matter if that library is in the classpath. There are 4 ways you can make the Java runtime load your shared library at runtime:
Call System.load to load the .so from an explicitly specified absolute path.
Copy the shared library to one of the paths already listed in java.library.path
Modify the LD_LIBRARY_PATH environment variable to include the directory where the shared library is located.
Specify the java.library.path on the command line by using the -D option.
Seems like your application is trying to find out a obidisc4j.dll (for Windows) or obidisc4j.so (for Linux). The file must be present on the PATH (but not the classpath). If you are not sure what PATH is your Java application searching in, you can write the following statement, before the point where the exception takes place, to find out the PATH.
System.out.println(System.getProperty("java.library.path"));
This will tell you about the paths where your DLL or SO file should be placed. You just need to place the file in ONE of those N-paths.
As the title states, I'm trying to use javap with eclipse but have difficulties setting it up. I'm trying to set it up using external tools from the run menu but can't find the correct Arguments: string to make it work. Basically I need something that will dynamically execute the current file I have opened.
I use the following external tool configuration to achieve this:
${system_path:javap} is used to locate javap in the JDK used by the Eclipse. You can use an absolute path to javap instead.
${project_loc} returns the absolute path to the project. This is used, since I could not find a pre-define variable to use, to locate the .class file of a resource, and that's why javap runs in the project's directory instead of the directory containing the .class file.
Among the arguments passed to javap:
bin is the default output folder for Eclipse projects. Change this to build/classes or whatever is used by the project. Note, the value is relative to ${project_loc}; you can specify absolute paths instead.
${java_type_name} is used to obtain the selected class name.
You can select a Java file in the Project explorer view or Project navigator view, or even a Java type in any of the views, and then run the external tool. Note - this approach doesn't work quite well when you select a method, an inner class etc. and then run the tool, as they are not resources on their own, leading to the scenario where ${project_loc} will be empty.
Your problem is that javap requres path to class file but when you select your source file you can access eclipse variable ${selected_resource_loc} contains path to java source. As far as I understand there is no variable that contains path to class file.
I think that the easiest way for you is creating your custom script that accepts path to java file, replaces java to class and source folder to bin folder. If you are using linux it it can be easily done using command sed. If you are on windows it can be implemented using command SET with ~. See help for more details.
Good luck.
Please try by modify the Working Directory to match your java project output folder. In my case, it looks as given below.
Working Directory: ${workspace_loc:/Sample/bin}
Then I selected the .class file and executed the javap without any issues.
In order to disassemble the currently selected .class file in Eclipse I use the following arguments in the External Tools Configurations.
This way classes in subpackages of the bin folder can also be disassembled. The output is displayed in the Console view.
Oracle documentation of javap parameters.
In-addition to the valuable custom script suggested by #AlexR; the other way is : Open the terminal windows within the Ecplise and run the javap command with -p and other option.
I am running a Java application from the command line. Can I specify a command line argument to set the current running directory to something other than where the application is actually going to run?
There is a JVM argument -Duser.dir which can be used to set working directory for JVM.
If it all possible I would rather use a script to run the java application and set the directory in the script:
#!/bin/sh
cd <your dir>
java <some arguments>
The JNI-solution may affect all kinds of relative paths in your application; for examples the classpath you put in.
If you want to change the current directory, you'll have to use JNI and invoke a native API from your Java code. For example, for Windows you would use SetCurrentDirectory
I found this SO post and it helped me solve my problem. Though I wanted to share something specific about IntelliJ that might trip somebody else up.
I have posted a picture below where the -Duser.dir flag is used and also the Working Directory text field is filled in.
In this situation, the Working Directory will be set to "JarLearning" rather than "2ndTry".