I'm currently using Ubuntu Linux. When I used to program on windows using eclipse, I could easily open javadoc when I hover over a function or when I press control and click it. Now I'm using VS code, and I can't see javadoc for some reason. When I hover over the function (Math.ceil for example) it shows some empty code that only returns 0 as in the screenshot attached.
I've already installed java extension pack. Any solutions to this?
Related
I am a software developer and am having a problem with Visual Studio Code while trying to run Java. When running other languages (such as python) there is a green triangular button on the top right that allows an easy way to run my code, however, when I trying running Java there arrow is not there and I have to manually select "Run Code" from the "Run" ribbon at the top of the screen. Is there any way that I could get the same green run button when using Java? Thank you for your time.
Press crtl+F5 to run without debugging and F5 running with debugger.
You can use the integrated terminal for compiling and executing by using the javac <filename>.java for compiling and java <filename> for executing.
Set your own key bindings.
Preset shortcuts
Install Java Extension Pack in extension marketplace will solve your question, also you can install Code Runner which provides button for code running too.
I have the Java Dependency Viewer extension configured in my Visual Studio Code and it used to work perfectly fine. But off late, whenever I open up VSCode and try to work on a Spring/ Maven Project, the Java dependency viewer fails to automatically load up on the explorer window (Waited for half an hour at times).
I have all the other important JAVA extensions already installed including the Language Support for Java(TM) by Red Hat.
Is there a way that I can manually toggle the viewer? Or, use any JSON setting to force rendering the viewer? Any suggestion ?
Note: I have tried disabling and enabling the extension, and I can see the viewer appearing. However, since this change causes the VSCode to reload itself, the IDE goes back to its initial state of not rendering the viewer.
Edit: I have JAVA (jdk-14), VSCode (v1.45.1) and Language Support for Java(TM) by Red Hat (v0.62.0) installed.
Have you tried to open a java file? Because the extension activated depends on the opened filename extension.
From here, you can know in which situations 'java dependency viewer' will get work:
"activationEvents": [
"onLanguage:java",
"workspaceContains:pom.xml",
"workspaceContains:.classpath",
"workspaceContains:build.gradle",
"onCommand:java.project.create"
], from official docs you can get to know the significance of every configuration.
But it's rare to miss all the conditions, so it's just in case. Then it looks more like there are some problems with the 'java dependency viewer' extension. you can reinstall it.
I'm using Visual Studio Code with the Java Extension. In windows, I get a highlight of all the errors in the IDE, as you can see in this screenshot:
But when I write the same code, with the same errors and with the same extensions in linux, the highlight doesn't work:
Before you say it, yes the error is there. If a run the code I get the error "Executer". Compared settings and are all the same. Java is detected, the thumb is up.
The version in linux mint and windows is 1.30.1.
If it helps, this is how I solved it:
Shift + Ctrl + P
Type Java: Clean Java Language Server Workspace and select it
Reload VS Code
So I am attempting to develop a JavaFX program using my favourite editor (Visual Studio Code) and then run that program through the windows 10 Command Prompt Command Line using
javac program.java
then
java program
I am currently running jdk & jre 1.8.0_181 (which I have been told already includes the JavaFX packages) however I keep getting compilation errors saying that the packages dont exist
Error: Package javafx.collections does not exist.
import javafx.collections.*;
^
I am currently in my third year of an information technology degree at university and on my university computers, javafx programs run completely normally just using the commands mentioned above however when I attempt to recreate these on my personal laptop, I get those errors. I know my program has no coding errors because it worked on their version with no compilation/runtime errors. If anyone can suggest any reasons why this may be happening (i.e. there is something I need to do to setup my javafx properly or I need to use a specific command to run the program) it would really help. Thanks.
So I was the one to originally ask the question but I just found a solution that happens to work and for those in the future who have this issue, I uninstalled ALL versions of java that I had running on my computer completely through the "Add or Remove Programs" page. Once done I installed specifically this version of Java (none of the others worked properly for me but this may differ for you): Java SE Development Kit 8u192 (Found at https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html). Once installed, find your Java directory in your Program Files directory "C:\Program Files", and open the jdk folder that you just installed. Get the path to this folder and copy it to the clipboard. Open your control panel, click on "System and Security" (if you cannot find this button, skip to the next step). Click on "System" > "Advanced System Settings" (on the left bar). Click the "Advanced" tab at the top, then "Environmental Variables..." at the bottom. Under "System Variables", look for a variable called JAVA_HOME. If you cannot find it, click "New", enter "JAVA_HOME" into the "Variable Name" field, and enter the path you copied to the clipboard earlier into the "Variable Value" field. Click "OK". Next find the "Path" variable and click edit. Look for a directory in the list similar to "C:\Program Files\Java{some jdk here}\bin". If you find one, click it, click delete on the right and then click new. Then in the created text field, enter "%JAVA_HOME%\bin". Click "OK" until all of the windows we opened are closed. The javac should now work with JavaFX.
I am new to Eclipse and Java programming having mainly worked with Microsoft Visual Studio.
I installed Eclipse (Kepler 4.3) with no issues along with WindowsBuilder and SWT.
I created a new project adding in references to SWT, both WindowsBuilder JARS, and resty. Into the project, I created a new package and selected a SWT composite. I gave appropriate names.
The GUI designer came up with no issues. I added in a couple of controls. The idea is to create a hello world application, display that application, and build it. Eclipse has automatically build checked.
Okay, the IDE in designer view shows the GUI of my Hello World application and the source view the source, so no problems there.
I press Run, and the first time I had to select a run configuration, which I selected EclipseStarter. There was not many options. I click on run and nothing happens.
If I go to the project's bin package folder, I see a file with a ".class" extension.
Why does pressing Run|Run (Ctrl+F11) do nothingness? There is a brief hour glass showing, but then nothing after that.
How do I launch the application from within Eclipse?
Is the generated ".class" file the correct runtime? I double click on that and Windows does not know what to do with it?
The end platform will be CentOS, but Java as I understand things, should be platform independent, so my Hello World application should run on my Windows 7 Pro box just as nicely. (I did not try CentOS yet) as I want to see it work on my desktop and know what file to copy over.
I think you selected the wrong option EclipseStarter.
Try running it as a Standalone Java Application.
It is a Standalone Java Application that you're building, right?
(I mean, the analogue of a Windows Forms App in .NET)
1. I guess because you selected the wrong type.
2. Ctrl+F11 is for Running it, F11 only is for Debugging it.
3. The class file has to be run by a JVM, Windows cannot run it directly,
it is not anything like a native executable or like a .NET assembly
(which Windows 7 knows how to run). But as you're using Eclipse you
already have a JVM.
The solution is multi-fold.
I had to delete Eclipse and install the 32-bit version of everything. That simplified life, as 64-bit caused issues running.
Create a new package
From the toolbar, select "Create new visual classes" drop down. Select "SWT" --> "Application windows".
Create the application window
Press the play button, 8th icon having selected the package first.
That enabled to run my Hello World on Windows. The output is a .java.
I still have a problem running from the command line, but that is a different issue.
Summary: My main issue was creating a SWT application window first and that I should have 32-bit for everything.