I am relatively new to stack overflow, VSCode, and programming. I am using a Mac. I downloaded VSCode for use with Python around two months ago. I can not run my code in VSCode but I enjoyed working in VSCode so I would write in it and run my code outside of it. Now I have the same issue with Java. I can not "solve," this in the same way because I do not know how I can run my Java code outside of an IDE.
I first read the instructions for setting up VSCode for Java on VSCodes website. I followed the instructions but when I tried to run a, "Hello world," program it said I did not have a debugger. I re-installed Redhat's Java support, closed and re-opened VSCode, and tried to run it again. This time it said java.jdt.Is.home is pointing to a missing or inaccessible folder. I looked this up found one description of this issue from 2018. I had a hard time understanding what it was asking me to do but at my best interpretation I wrote "which java," in Terminal and copy pasted what it returned (usr/bin/java) into settings.json after "java.home: ". This gave me an error stating that it is outdated and I should change it to, "java.jdt.Is.home: " so I did. I also tried adding "local/" between "usr/" and "bin" as it appeared in my path to my Python3 interpreter. All of these gave me the same error when I tried to run a hello world program.What can I do to solve my issue with Java in VSCode?
which java can not get the right java home.
You need to take /usr/libexec/java_home or /usr/libexec/java_home -V.
Java home on MacOs looks like: /Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home
But You need not set the "java.jdt.ls.java.home" at all. Because the JRE has been embedded in the Language Support for Java(TM) by Red Hat extension.
Only the universal version without embedded JRE can specify the java.jdt.ls.java.home manually. Otherwise, it will search JDK_HOME JAVA_HOME current system path.
You can refer to the official dosc.
So, have you installed the related extensions? You can install Extension Pack for Java, which contains the extensions you need.
I am a little confused about why you can not run the python or java codes, it's very rare. After you installed the related extensions(Python Extension Pack) , just right-click in the editor, you can select the Run Java Debug Java Run Python File in Terminal and so on. Or you can click the button on the top-right.
Related
I recently moved from windows 10 to Ubuntu 16.04, I'm a java developer, when I was on windows I installed Vs Code with the java Extension pack. On windows I never Had problem to make my daily work, but on ubuntu, every java file is marked as error, with the message "The import cannot be resolved", searching a litle bit, i found that you can execute the command java:clean the java language server workspace, but this does not fix the problem. I also remove the tmp files from the workspace located on:
~/.config/Code/User/workspaceStorage
the current Version of Vs code is 1.41.1
the current version of Java Extension Pack is 0.8.1
Any ideas?.
Regards!.
Edit:
all my java files are marked as error
inside of every java file
this is the result of the maven-install
well, after a while of searching, I found that the "maven for java" plugin was trying to download the maven plugin maven-metadata.xml, which wasn't available on my repo. this caused a conflict with the initial build that maven for java was doing. to avoid to update every time I opened vs code, I removed the option "update snapshots"
And the initial build was done.
I've been having trouble using NetBeans IDE 8.2 with JDK on Windows 7 64-bit. NetBeans can compile code, but doesn't run it. I've downloaded all of the necessary files and programs and even consulted with a computer programming teacher, but I haven't been able to work around this issue. The URL displays an image that shows what I get back after attempting to run a code.
https://i.stack.imgur.com/RsEvx.png
I appreciate any help I can get.
Thanks,
--Sam
JavaApplication1.java is still set as your main class.
To change your main class, go into Project Properties -> Run and change "Main Class" to TestClass.java.
Essentially, the compiler is still running whatever main function is found in JavaApplication1.java.
#notyou Also mentioned how you can right click a file and run it directly, instead of changing the project settings. I used to use this but it slipped me! This is super useful.
I'm pretty sure this question has some answers for you.
I'm very new to Java and computing in general. Currently taking an intro to programming course revolving around Java.
I got a notification earlier about a Java update when I wasn't using it and accepted it without much thought. I just now tried to open Eclipse to start doing some homework and when I did, all I got was the following message:
A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations: C:/Program Files/Java/jre1.8.0_144/bin
I have no idea where to go from here. I can't get in touch with my web developer friend helped me set up Java on my computer originally, and my instructor isn't responding to emails. I've tried to fix things like this myself in the past and have only compounded the problem, so I'm reluctant to try anything I'm not certain about, which is to say I'm reluctant to try anything at all. Any help is appreciated.
First, try to find where your jdk locates. If you don't remember where you have installed it, try to search for jdk or jre folder in C:/Programm Files. Then go to Window -> Preferences -> Java -> Installed JRE's tab in Eclipse and set path to your jdk or jre.
Got it figured out from an old question- just had to change the text to the updated JRE in the Eclipse initializer. Thank you for your help!
I'm having a frustrating issue with a java program I have been working on. I have not had this issue often in the past and I have actually created many versions using this same code and had no problems.
Suddenly, executable JARs of this program will not start. I have tried running them through the command prompt with Java and I get message about the main class not being found.
I have done a search here and none of the answers work for me. I have tried the following:
Removing the system library in the build path settings and adding it back. (The system library is [jre1.8.0_66]).
Changing the compliance settings from 1.7 to 1.6. I don't have an option for 1.8 and the JDK check box that says "Use compliance from execution environment on Java Build Path" is disabled.
Removing the main class and adding it back.
Using the package and export options for libraries.
I'm really not sure what else to do. I've tried doing a rebuild on the project many times and also tried restarting eclipse and re-exporting. I'm certain that I am selecting the main class when in the export preferences.
Any help or suggestions would be greatly appreciated as this has become very frustrating.
From the comments, it seems to me that you are not executing your JAR correctly. As stated in the comments, you are executing your JAR with java {jarname}. This syntax would only work with running a compiled Java class with a main method. To run a JAR, use:
java -jar {jarname}
Hi i've been trying to install the library on Thinking in Java book 4th edition and i hit a very thick brick wall. I've done everything that the guide from the website told me to do and i still can't get the library to work. From what i've read it seems that the problem is from the build.xml files. having no xml knowledge I am clueless about how I have to modify it in order for it to work. In both cmd and eclipse I am getting these error
c:\TIJ4\code\build.xml
Build Failed
c:\TIJ4\code\build.xml:59:J2SE5 required
Can anyone tell me what I should do ?
I am using eclipse if there is a simpler solution by using eclipse rather than ant please help me out. It's been a week now and I still can't make it work.
The important thing to do is to realize that your ant file has a specific java requirement.
Something to try that might fix this very easily : I believe you can remove any references to a specific JDK, and if you have a reasonably up to date JDK, the build will succeed.
The definete fix : Look into the exact (line 59) of your build file, and try to satisfy the java version that line requires. Java is generally backwords compatible -- something designed to run in J2SE5 should run in the latest JDK. Its not terribly difficult to update your JDK (just google for instructions on your OS).
The most common mistake I see is that people who have the java run time installed believe they also have the Java SDK as well.
Does this "install the library" means you want to look at the code and run them in your eclipse? If so I can share my experience with you.
First run the Eclipse.py script; this will add package info to the source code
Create a new Java project in Eclipse, and then just copy all the source code folders to the src source folder in eclipse, these folders will then be recognized as Java packages.
You should be able to run the classes with a main function.
You can also configure which java version to use for this project in Eclipse build path. 1.5 or higher will work.