I am getting started with Jena and semantic technologies (I am taking a class on the topic). The lecturer recommends using Eclipse as IDE, but I would like to use Visual Studio Code. How can I import apache.jena? I would like to get information/error messages as you would with any other library.
I have had amongst VSCode's extensions, but did not find any support.
I include "import org.apache.jena.rdf.model.;" and get a "not found" error when I try to compile - unless I also include "-cp "/path/to/apacha/jena/on/my/computer/:." when compiling and running the program.
The goal is to be able to compile and run without having to include a path to the library and if possible, for VSCode to have an understand of the library (giving me warnings, suggestions, error messages osv.)
Use Java in VSCODE. You need to install the Extension Pack for Java, and the documentation contains more information.
Use VSCode to open the Java project folder, expand the project structure and display it on the JAVA PROJECTS panel.
Click the plus icon next to Referenced Libraries to add a .jar file reference. Of course you need to download the Jena library on your machine first.
Or use the following configuration in setting to add reference.
"java.project.referencedLibraries": [
"/path/to/jena/lib/*.jar"
]
Related
I am now coding Android apps without using Android Studio, and when I compile, I encountered the errors:
./src/com/example/projectname/GamePanel.java:8: error: cannot find symbol
import androidx.annotation.NonNull;
where the "^" points at the period before "NonNull", and
error: package androidx.appcompat.app does not exist
And my compile command is:
javac -d obj -sourcepath src -classpath ../android/platforms/android-32/android.jar ./src/com/example/projectname/*.java
The internet tells me that I should set android.useAndroidX to true, but I am not using Android Studio. Is there any way to let javac know that I am using AndroidX?
OK, so the problem is that the NonNull annotation is not defined in that JAR file. (Or at least, not in the android.jar that I found ... on Github.)
I managed to find a JAR containing androidx.annotation.NonNull in the Maven Central Repository: https://mvnrepository.com/artifact/androidx.annotation/annotation/1.3.0
But I suspect that you are going to find more of these issues as your project gets more complicated.
Is there any way to let javac know that I am using AndroidX?
No there isn't. The javac compiler understands nothing about Android let alone AndroidX. It only knows about what you added to the compile-time classpath. So if you are going to persist with compiling using javac directly, you are going to have to figure out how to find the JARs that you need for yourself1.
My recommendation would be:
Just use Android Studio. It really isn't that slow ... when you take into account all of the features it provides to make coding, testing, debugging, etc.
You can also use the Gradle build tool2 independently of Android Studio. It has a plugin designed especially for building Android apps; see https://developer.android.com/studio/build. Among other things, it will automate the downloading of the dependencies and the configuration of the classpath.
1 - And down the track you will need to manually update the JARs that you manually downloaded, etc.
2 - There are alternatives such as Maven, Ant and so on, but AFAIK Gradle has the best integration for Android.
Is there any way to let javac know that I am using AndroidX?
Yes, you can download the JAR files for the libraries you are using and add them to the classpath.
However, this leads down a path of suffering and sadness because you will have to download many different JAR files that are implement different parts the androidx package, depending on what features you need.
I strongly suggest you to use Android Studio. It is an incredible tool that makes Android development easier than it otherwise would be.
If your goal here is to compile your app from the command line, then you need to learn about gradle. This is a tool that will download the dependencies for you then run javac with the correct classpath set. Basically it automates all the steps you would need to take to do this manually.
So i have tried to find an answer but didn't manage to do it yet. What I'm trying to do is to write a Java code for example in Atom editor, and compile it on Atom itself, without the need of an integrated development environment. Same goes with adding classes to a project.
Is that possible?
Yes. That is how they wrote the first Integrated Development Environments. Although the compilation step is typically performed externally from the editor, if the editor can execute external programs then you can "integrate" compilation. Adding "classes" is a little more involved, in that it requires your "editor" to understand the packaging and structure of the files composing the classes - at that point you have an integrated development environment.
Yes it's possible with atom package build. To install the package Edit-->Preferences-->Install and type build and hit Enter. Then you should configure your custom build command as mentioned in official package website. You may just fill cmd: javac in yml file for example
You need to install a package that will compile. Atom is a hackable text editor but not really an IDE as you pointed out. That said there are a lot of packages for compiling and for working with java.
You can look at Build Tools Package for compiling. It looks like it will work for Java but there are many compilers in the package list.
I would search on their package site for the keyword "Java" to see what java packages you might want to use. Then do another search for "Compile" to see what compiler you might want to use if the build tool above doesn't work for you. You can search atom packages at https://atom.io/packages.
I use IntelliJ IDEA 12, Play 2.2.0, I have Scala plugin installed, Play 2.0 support plugin installed.
I created java play application via termina (play new). Andas you can see in this pictures I always get this error: "cannot resolve method ok()" or "cannot resolve symbol at"
http://sluchatka.kvalitne.cz/pics/1.png
http://sluchatka.kvalitne.cz/pics/2.png
I searched the web for this problem the whole day, but I didn't find solution.
Can you please help me?
The first problem (unable to resolve reference to template) is because your template probably has not been compiled by the moment (and thus IDEA does not see compiled template and can't resolve reference to it).
I usually develop Play apps having ~run command launched in Play console. So that any changes to templates are immediately compiled and changes detected by IDEA.
As for the second one it seems like a deficiency in Play IDEA plugin. It does not work seamlessly within templates I should say. Lots of glitches. The best way I found is to have ~run launched so that small problems are detected immediately.
According to intelliJ support it is better to import the command line created play 2 project using the IDE import project wizard instead.
File -> Import Project
Select play2 project location
Import as SBT project
This was due to the "play idea" command being outdated or not fully compatible with the current play 2 and scala plugins for intelliJ.
A bonus is that errors start to appear properly, we had trouble with that earlier.
I was having a similar issue with Play 2.4.2 and Intellij 14.1.4. I could run the basic "play-java" example/starter app in Intellij, even though the editor showed errors like "cannot resolve method ok()".
Here's what solves the problem for me:
Before starting, make sure your project is not open in Intellij.
Delete the ".idea" folder from your existing app, OR just create a new app using "activator new".
On the command line, cd to the app's folder and compile using "activator compile".
In Intellij, File -> Open, and select your app's folder. For the SBT import options, I left the boxes unchecked (e.g. "Use auto-import", "Create directories for empty content roots automatically", etc.) but I don't think it matters.
Once everything finishes loading, you shouldn't see the errors any more.
This click in the Project Structure is your answer.
In Eclipse, using the CCW plug-in, I want to load a clojure file into a REPL. The problem is that I have an import statement for one of my own java classes, but apparently it is not in my classpath.
(ns my-clj-ns
(:import [alg.gen Enumerator]))
Do I have to make jars out of every class that I want use/test in a Clojure REPL?
Currently, trying to load my clj into a REPL results in an error:
"Load file in Clojure REPL" did not complete normally. Please see the log for more information.
java.lang.NullPointerException
Any help would be greatly appreciated.
You can let leiningen compile these for you using,
:javac-options {:destdir "classes/"}
:java-source-path "src/main/java" ; location of Java source
options or manually compile them and move the class files to the classes/ directory. No need to create a jar.
When you're in the ccw repl, you can hit alt-e to see the stack trace. If you're getting a NullPointerException, I don't think its a classpath issue.
Your code looks fine to me.
I suspect the issue is with your Eclipse Java Build Path, which determines what Eclipse includes in the classpath for your application.
In particular, if your Java class is in a separate project, you will need to either add that project to the build path (right click on project / Properties / Java Build Path / Projects) or package it as a jar.
When you start to have more sophisticated build requirements, you may also want to start looking at Maven to handle this kind of thing for you. Maven is a pain to learn / set up in the first place but it pays of in the long run.
Leiningen is also a great tool to use but I personally don't use it for the following reasons:
It is great on the command line, but doesn't integrate so nicely with an Eclipse workflow
Maven is more widely used and better supported in the Java world
There is really nice guide if you want to learn how to do this.
https://github.com/technomancy/leiningen/blob/master/doc/MIXED_PROJECTS.md
But in gist, have a project definition like the following for Java source code.
(defproject megacorp/superservice "1.0.0-SNAPSHOT"
:description "A Clojure project with a little bit of Java sprinkled here and there"
:source-paths ["src/clojure"]
:java-source-paths ["src/java"])
I'm trying to use the JNotify library along with netbeans, however I don't know the proper way to configure it. Everything I try, the lines involving jnotify (eg. import net.contentobjects.jnotify.*) are underlined in red. Google seems to show nothing helpful regarding netbeans with jnotify, although I assume it's something simple like adding it to the classpath. I've tried adding the .jar as a library for compile & for run, no go.
The line i've been provided for running my app from the jnotify page:
-cp jnotify.jar -Djava.library.path=.
should I be using this as my compiling options or VM run options or both? seeing as I don't want to have to distribute my app with a .dll or .so file or the jnotify .jar.
Everyone on this site recommends using such and such a library, but they don't realize how hard they can be to set up (jnotify,boost,curl), and most who recommend them have probably never even used them themselves.
You're right, you have to add every library you use in your programs, into the projects classpath:
Click on the project node in your 'Projects' window. It should by default have a node called 'Libraries'.
Right click this node and select 'Add JAR/Folder'
Locate the JNotify.jar on the file dialog and press 'Open'.
Refresh your project, or just give netbeans some time to rescan the classpath, and you should be good to go.
There definately is something wrong with your classpath. While the above is exactly how you set the classpath when running a Java program, its different for a NetBeans project.
Follow these articles on how to add extenal jars to a NetBeans project.