Java Compiling issue when first using vscode - java

I have been using vmware to log into the lab machines at my uni. I just started using vscode on my pc. I installed latest jdk 16.0 and i installed the java extension pack from vscode. But it still wont let me run or compile my program
I keep getting this error, thought it was an issue about the paths after a little bit of research so i made the java:home path to where jdk folder is in my c drive and i still get this error:
c:; cd 'c:\Users\Aaron Mark\Desktop\UNI\FinalAssignment'; & 'c:\Users\Aaron Mark\.vscode\extensions\vscjava.vscode-java-debug-0.34.0\scripts\launcher.bat' 'C:\Program Files\Java\jdk-16.0.1\bin\java.exe' '--enable-preview' '-XX:+ShowCodeDetailsInExceptionMessages' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\Aaron Mark\AppData\Roaming\Code\User\workspaceStorage\2bfa7b3e373492b1fc42e07c42d17320\redhat.java\jdt_ws\FinalAssignment_fe08a03d\bin' 'QuestionOnePartA
How do i fix this class not found error?

I think you point to the blue sentences displayed before the real output, actually they are not errors but execution scripts, which shows the necessary building and compiling commands to get the output:
If you don't want to see these scripts but pure output, create a launch.json and add "console": "externalTerminal", in configurations. Run without debugging(Ctrl+F5) can open a new external Terminal and no execution scripts shown:

This is not error.
IDE is printing all the program being used for compiling and running the code.
'-cp' : this is your classpath. You can add more external library using it.

Related

JAVA : Program Works in Terminal , But not in Visual Studio Code : Mac OS

My JAVA Programs used to run without any errors on both the Terminal and Visual Studio Code's Terminal .
After my Mac updated to MacOs Big Sur Version 11.0.1 , my JAVA programs show an error , even though the same code worked properly before .
There was no error before.
I checked my JDK and JRE Installations also
My Python files execute normally in the VS Code environment , so I do not think there is a problem with VS Code .
I have tried searching for an solution and have tried to clear the logs.
I would appreciate if anyone could guide me :)
Run the .java file in Terminal to check if JDK can work normally:
javac Hey.java
java Hey
If there's nothing wrong with the above command execution, turn to VS Code, uninstall Java Extension Pack and also delete the related folders under User/name/.vscode/extensions, then reinstall it again;
Set java.home and java.configuration.runtimes in User Settings.json.
Reference: Configure JDK.
Then run the project again to see if the problem goes away.
Install Java by searching for extensions in VSCode and try to run again.It will be executed. I belive it is not installed
You need to install the java plugin in VS Code.
Hi just found a solution here!
Initially guess it should be a problem with zsh.
so first open your terminal and type
open ~/.zshrc
at this point you will see text editor pops up with a zsh config file.
Add
export JAVA_HOME=`/usr/libexec/java_home
to the last line in that file, and save the file quit.
Then just reopen the VSC and you will notice everything would back to normal as usual.
I faced a similar problem. When running the same Java program, it worked in terminal but VS Code couldn't detect java.
All it turned out to be was I forgot to add Code itself to Path after reinstallation, nothing to do with Java.

Error loading python27.dll (error code 14001) while running Jython script by cmd

I have installed Jython on my Windows 7 machine, something I did often. I have set the environment variable PATH with the path C:\jython2.7.1\bin\ and I launched the program from cmd as jython myProgram.py.
The following error appears:
Error loading Python DLL: C:\jython2.7.1\bin\python27.dll (error code 14001)
I've also tried to launch the program with C:\jython2.7.1\jython.jar myProgram.py and it works! The problem is that I can't debug at runtime.
Why that error while I run jython myProgram.py? It had never happened to me before. Yet the python27.dll file in the bin folder is there! I hope it's nothing serious.
On Windows 7 you are using a too high version of Jython. Go to this site, download and install the 2.7.0 version. After that, set the PATH environment variable as C:\jython2.7.0\bin.

Issue running tensorflow with java

I am having some issues running tensorflow with java. I am using CUDA 8 with CuDNN 6.
I tried following the quickstart instructions located here: https://www.tensorflow.org/install/install_java and get the following error message when I attempt to run the example java program:
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
Exception in thread "main" java.lang.UnsatisfiedLinkError: Cannot find TensorFlow native library for OS: linux, architecture: x86_64. See https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java/README.md for possible solutions (such as building the library from source). Additional information on attempts to find the native library can be obtained by adding org.tensorflow.NativeLibrary.DEBUG=1 to the system properties of the JVM.
at org.tensorflow.NativeLibrary.load(NativeLibrary.java:75)
at org.tensorflow.TensorFlow.init(TensorFlow.java:66)
at org.tensorflow.TensorFlow.<clinit>(TensorFlow.java:70)
at org.tensorflow.Graph.<clinit>(Graph.java:258)
at HelloTF.main(HelloTF.java:8)
The jni directory contains the following:
libtensorflow_framework.so
libtensorflow_jni.so
LICENSE
I then tried installing the binaries from source as suggested here:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/java/README.md
This is the output from setting: org.tensorflow.NativeLibrary.DEBUG=1
org.tensorflow.NativeLibrary: tryLoadLibraryFailed: /path/to/jni/libtensorflow_jni.so: libcublas.so.8.0: cannot open shared object file: No such file or directory
org.tensorflow.NativeLibrary: jniResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_jni.so
org.tensorflow.NativeLibrary: frameworkResourceName: org/tensorflow/native/linux-x86_64/libtensorflow_framework.so
But I still get the same error message when I try and run the example Java program.
What am I doing wrong??
Any help would be greatly appreciated!
The error
Cannot find TensorFlow native library for OS: linux, architecture: x86_64.
is clearly stating that the library is not visible to your software.
To make it available to the Java class, try doing like that (in the same shell obviously):
export LD_LIBRARY_PATH=/the/absolute/path/to/your/library
java -cp libtensorflow-1.4.0.jar:. -Djava.library.path=./jni HelloTF
also ensure you're running the java command from the same directory which contains the /jni directory.
For those landing here and facing the same issue.
You are probably trying to run your program from eclipse. Then, you have to go to Run configurations > Arguments and pass this arguments:
Program arguments -> models/
images/example-400x288.jpg
VM Arguments -> -Djava.library.path=./jni
like in this screenshot:
When people (like myself) come from python to java world, everything is strange! here is how I solved my problem regarding all linking errors:
I assumed you already have simple hello Tensorflow project, explained here
Download and copy tensorflow JNI files to :/usr/lib/tensorflow
Download and copy desired version of tensorflow Lib jar file to: /usr/lib/tensorflow
Compile with java
Compile java file
javac -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar HelloTensorFlow.java
run java file:
java -cp /usr/lib/tensorflow/libtensorflow-1.14.0.jar:. -Djava.library.path=/usr/lib/tensorflow/ HelloTensorFlow
use MAVEN
First we should export LD_LIBRARY_PATH:
export LD_LIBRARY_PATH=/usr/lib/tensorflow
Then run maven build command:
mvn -q compile exec:java
I hope it helps you

Android.bat can't run java

I know this question has been beaten to death but I still cannot get the SDK Manager to run on my Windows 7 Home.
I downloaded the eclipse + adt bundle. The SDK Manager.exe is in the sdk folder where I try to run it from. I even tried copying it to the tools folder and tried running from there but no luck.
The error I get is:
Failed to execute tools\android.bat:
The system cannot find the file specified.
The file clearly exists. I tried running it as "Administrator" as well.
Next I tried running the android.bat file itself which says:
Windows cannot find 'E:\path\to\batfile'.
Make sure you typed the name correctly, and then try again.
I then ran it as "Administrator" which at least detects and tries to execute it. I added in a few pause statements to android.bat itself to prevent it from closing.
Here is what I see:
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s' is not recognized as an internal
or external command, operable program or batch file.
ERROR: No suitable Java found. In order to properly use the Android Developer
Tools, you need a suitable version of Java JDK installed on your system.
We recommend that you install the JDK version of JavaSE, available here:
http://www.oracle.com/technetwork/java/javase/downloads
If you already have Java installed, you can define the JAVA_HOME environment
variable in Control Panel / System / Avanced System Settings to point to the
JDK folder.
Not sure why it says that because when I run where java in cmd I get this:
C:\Users\(MyUser)>where java
C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
C:\ProgramData\Oracle\Java\javapath\java.exe
C:\Windows\System32\java.exe
And when I open cmd and manually run
'"E:\ADT\sdk\tools\lib\\find_java.exe" -s'
it works fine.
I then tried setting the java_exe in android.bat to
set java_exe=C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
After commenting out the find_java I ran it again and this is what I get:
'"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar lib\archquery.jar' is not
recognized as an internal or external command,
operable program or batch file.
Invalid path
And once again, when I manually run it, I get:
C:\Users\MyUser>"C:\Program Files\Java\jdk1.8.0_05\bin\java.exe" -jar E:\ADT\sdk\t
ools\lib\archquery.jar
x86_64
Am I missing something or should I finally give up trying to get it to work on my windows machine.
Your where java shows too many java.exe, the find_java.bat will try to look for javaw as well in the folder where java is.
set JAVA_HOME and make sure the echo %PATH% points to your main jdk installation.

Error when starting Datomic shell: java.lang.NoClassDefFoundError: jline/ConsoleRunner

I followed the instructions on the Datomic site: http://docs.datomic.com/getting-started.html, but I'm getting this error when trying to start up the datomic shell prompt. I'm using a windows machine. Any suggestions? I tried the same thing on my linux box and did not get this error.
Edit: moved to a different windows machine and it's working. If I have time to troubleshoot this problem and I find a solution I'll report back
I noticed that you cannot run the shell.cmd from within the bin directory, you need to call it with bin\shell.cmd from the parent directory... hope that helps.
In case you are using cygwin/bash and call bin/shell :
The java runtime on windows does not understand classpath with a ":"
but this is what you get from bin/classpath.
Either correct this or use DOS-CMD shell and call bin/shell.cmd inside.
Regards
Some tips for running datomic on Windows (7 at least):
Do not download datomic into Program Files. On startup, it creates logging directories and temp files into its own directories, so unless you run the command prompt as Administrator, you're gonna have screens full of Unable to write to file... errors.
You need to run datomic as such (assuming you extracted the download to C:)
c:\datomic-free-0.x.xxxx>bin\shell.cmd
Note the backslash. Tripped me up forever coming from *nix world.
After that, return to your regularly scheduled datomic tutorials.

Categories