Visual Studio Code Java compile multiple classes and import jar-s? - java

I am switching from NetBeans to VS Code Java on Linux and I am unable to run or build my projects. I get error: cannot find symbol for every class declaration or external package usage.
How do I build all the .java classes in a project folder, not just the currently opened one?
How can I import .jar in VS code?

Related

Unable to import java.lang.instrument in Android Studio

I am trying to import the Java Instrumentation library (java.lang.instrument) https://docs.oracle.com/javase/7/docs/api/java/lang/instrument/Instrumentation.html in my Android Studio project but it is complaining that it isn't able to find it.
From what I understand, this library should be built in to Java. While typing in java.lang, I do see existing classes under that package.
Does anyone know how I can use this specific class in Android Studio?
I have tried looking into the Gradle file where dependencies are declared but I am confused as java.lang is built into Java.
I was expecting the java.lang package in Android Studio to contain the Instrument class.

jasckson libraries in google app engine not included in whitelist

when I have these imports in my code or use any of the classes and and methods, I get this error from intelli J IDE.
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
Class 'com.fasterxml.jackson.databind.ObjectMapper' is not included in App Engine JRE White List
this does not result in any Maven build errors but or any errors in production. but why is the IDE flagging the error.
Class 'com.fasterxml.jackson.core.type.TypeReference' is not included in App Engine JRE White List
Those imports aren't part of the Java Application Programming Interface (Java API)
They are library that are created and in order for you to use them, you have to download and add the jar file in your java build path library

How to resolve issues with using external packages in IntelliJ?

I recently switched from eclipse to Intellij and hence I am new new to it. Till a day before I was successfully able to compile my java program (maven) and generate output. The program uses multiple external packages and also Rserve to connect to R. However, when I tried to compile it today, it does not recognize any of the external packages and gives multiple errors like:
Error:(25, 26) java: package org.rosuda.REngine does not exist
Error:(22, 53) java: package org.apache.commons.math3.optimization.fitting does not exist
On looking through the project structure, in the dependencies tab, it shows something like the following image. Can someone please help me finding the issue here?

Creating a Java jar library to use on Android project

I am working on developing a game for Android and I have a lot of the code written on a java application. I would like to use the classes and methods in the Java application within my Android application. I am using Eclipse to develop my application so I tried to create a Jar for the Java application By doing: Right click project->Export->Jar I then saved the jar somewhere and added the jar to my Android buildpath. When I try to use methods from that jar I get compilation errors because Eclipse cant find the methods. Am I supposed to have any import statements? The name of the package on my java app is (default package) so I am not sure what the import statement would be. I would appreciate any help.
EDIT: I changed the package name of my application so that I could import the classes within it and that got rid of the compilation errors. When I try to run the project I now get NoClassDefFoundError Could it be that I am exporting the jar for my Java application wrong?
Open Project properties -> Java Build Path -> Order and Report tab.
Try to check jar check boxes,
see example:
To make sure that you created jar properly, here other snapshot of jar export:
Rename the package first. http://docs.oracle.com/javase/tutorial/java/package/namingpkgs.html
Yes, you need to import the package inorder to use in a class. Else the compiler will not identify the codes. Import the jar into build path and import the package into the Java code as :
import java.util.HashMap;
If I understand your correctly you exporting a Java .jar (built using Java compiler)? As far as I know Android does not understand Java bytecode though the compiler for Android understands Java source code.
I'd suggest you just put all that source files in the Android project and compile them there, hopefully you aren't using functions that Android API does not have.

Eclipse project can't find itself in class path

I'm using Eclipse Juno and trying to import a java project created with an earlier version of Eclipse on a different operating system. After importing the project and trying to run one of the java files, I get this error: The project: OldProj which is referenced by the classpath, does not exist.
But the file I'm trying to run is in the OldProj project, so it's saying it can't find itself.
It's a stand-alone project. It doesn't reference anything outside itself, not does anything else reference it. It is the only project in the workspace, in both versions.
I tried importing the project through the Import... command. I tried creating a new project and just copying the source files over. Both get this result. The project still runs fine on the earlier version.
This is a new install of Eclipse, so perhaps I missed a setting or two. Does anyone know what I missed?

Categories