How to fix the compiler error in this program? - java

So i'm a student in high school new to the Java language and i'm using this program called jgrasp, which we use to program java. I just got the program for home to try to finish off a lab I was working on and when I compile, this shows up:
----jGRASP exec: javac -g EqualToThree.java
----jGRASP wedge2 error: command "javac" not found.
---- This command must be in the current working directory or
---- on the current system PATH or jGRASP PATH to use this function.
---- System + jGRASP PATH is "C:\Program Files\Java;C:\WINDOWS\system32;C:\WINDOWS\system32\wbem;C:\Program Files\QuickTime\QTSystem;C:\Documents and Settings\Andrew\My Documents\Downloads;C:\WINDOWS\system32;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\QuickTime\QTSystem\".
---- Use Settings > PATH/CLASSPATH > Workspace (PATHS tab)
---- to add directories to the jGRASP PATH.
----jGRASP: operation complete.
I just recently upgraded my java to the latest version, and I honestly have no idea how to fix this. I did go to the class path, and selected the selected files it wants, but still no luck. Any idea?

I had a similar problem, I do not know if it is specific to windows 7 or what.
I had installed several copies of the JDK thinking that would automatically fix it. It did not. Jgrasp somehow had multiple paths to the Java Compiler (javac), and the first one it went to was the JRE.
I solved it this way:
I went to SETTINGS/ PATH/CLASSPATH / PATH(tab) / PATH(tab)
click New
(in a seperate windows explorer window I verified the correct path to the JDK)
and added
C:\Program Files\Java\jdk1.8.0_11\bin
click Apply
click Ok
That fixed it, and made the bad frustration go away.

I'm with the same problem and then found the jGRASP install documentation. It suggest the following:
Go to the Settings > CLASS/CLASSPATH > Workspace
Select the CLASSPATH tab, if is not already selected, then click 'New'
In the dialog, click the Browse button for 'PATH or JAR file' and navigate to the JAR file or the folder containing the target Java package root, and click the Choose button.
I found all that in the documentation: https://www.jgrasp.org/tutorials187/01_Installing.pdf

Related

Eclipse error: org.eclipse.core.nternal.resources.Project cannot be cast to org.eclipse.core.resources.IFolder

I have jdk 1.8.0_191 and Eclipse 2019-12.
This is what I'm doing:
Opening Eclipse
File > New > Dynamic Web Project
Fill Project name > Click next
On "Source folders on build path" it's empty. I just click next.
Fill "context root" and "content directory" with a value
Check "Generate web.xml deployment descriptor"
Click finish
Getting the following error when I click "Finish":
Failed while installing Java 1.8
Then there's an "Ok" and a "Details" button.
When I click "Details" it says:
org.eclipse.core.internal.resources.Project cannot be cast to org.eclipse.core.resources.IFolder
Then I click "ok", it closes the window and creates a folder with the project name. But the folder is empty. It does not contain all of the other files and folders that should be there for a Dynamic Web Project.
I found the issue.
Executed the same process in Eclipse 2021-03 and it worked.
Realized that the issue was on the second screen ("Source folders on build path").
In Eclipse 2021-03 that screen came already filled with the following info:
Source folders on build path: src\main\java
Default output folder: build\classes
But on Eclipse 2019-12 those two fields were empty.
So I just added that same info manually, proceeded to the end and it worked fine.
For some reason those fields are empty in that version of Eclipse in my machine (not sure if that's default for that version or it's something in mine. Most likely the second.).
Anyway, filling them manually resolves the issue.
Thanks.
You might find more details in file $workspace/.metadata/.log - most of the times something that goes wrong internally shows up there before the problem gets visible to you (the cast exception is probably a follow-up error, and in itself not telling much).
If there's nothing immediately remedying in there, you could file a bug report in the Eclipse bug tracker (with log file provided), and hope that someone will investigate what might have gone wrong in the two year old release.
Does the problem persists with current versions of Eclipse and JDK (where development is focused)?

Supplied javaHome is not a valid folder in eclipse

I have migrated a workspace to a new machine with a different java distribution.
The old machine had java-11-openjdk-amd64.
The new one has only corretto.
Upon opening the old workspace on the new machine I get some problems, such as
Supplied javaHome is not a valid folder. You supplied: /usr/lib/jvm/java-11-openjdk-amd64
line 0 Gradle Error Marker
So in the workspace I deleted .metadata and I searched the workspace (and ~/.eclipse, ~/.gradle just in case) for references to the old version with
grep -r "/usr/lib/jvm/java-11-o"
There are no results.
I have made sure that no eclipse processes are running (ps -aux | grep eclipse) and restarted eclipse, but the errors remain. What else can I do before creating new project and manually copying the code?
Sounds like the right place to edit this is in the eclipse preferences, and/or that eclipse is picking this up from an erroneously set JAVA_HOME environment variable.
Window > Preferences > search the filterbox for 'installed' to get to 'Installed JREs', remove any entries that don't seem right and add your coretto install here.
Next check Window > Prefernences > Gradle > Arguments > Java Home, and fix things here. Most likely you can just select 'workspace JRE' and that should fix the problem.
If that doesn't work out, there's always the option of adding to your ~/.gradle file a single line with:
org.gradle.java.home=/path/to/coretto
I received an update to my VM and the previous Pref>Gradle>Arg>Java Home no longer existed. I cut and pasted in one that did... Unfortunately, this did not work. I had to come through Eclipse and use the file navigation to get to the new Java Home I wanted to use. (Then do a Gradle>Refresh Gradle Project to get it to take).

Issue while installing Realignment for JD-Eclipse

I'm trying to debug a .class file using JD-Eclipse plugin. But while debugging some of the decompiled lines are skipping even after placing the break points in desired lines. After googling i came to know about another plugin called "realignment.jd.ide.eclipse_1.0.2.jar".
I performed the install procedure as per the SourceForge page and tried dropping the jar file in eclipse /plugins directory and restarted the eclipse(Also tried the /dropins directory). As per the site If we go under this Preferences/General/Editors/File Associations and select "*.class" file type. There we should choose "Realignment for JD Class File Editor" for Associated editors. But there was nothing as expected. Please someone guide me in right direction to use this realignment feature.
Current Environment:
Eclipse IDE : Eclipse Kepler
JAVA : JDK 6
Thanks in Advance.
You don't need the Realignment plugin. Just install the JD-Ecplise plugin, go to menu Window > Preferences, navigate to Java > Decompiler and check 'Realign line numbers' (you can uncheck 'Show original line numbers' since they will match the decompiled class text)

The program suddenly stops somewhy. How could I solve this? [duplicate]

Can anyone help me with this error:
java was started but returned exit code = -805306369
C:\Windows\System32\javaw.exe
-jar C:\Program Files\Java\eclipse-jee-helios-SR2-win32-x86_64\eclipse\plugins\org.eclipse.equinox.launcher_1.11.1.R36x_v20101122_1400.jar
Just had this issue, for me it was a corrupted workspace osgi cache. The solution was to run eclipse with the -clean parameter as
eclipse.exe -clean
After some time, eclipse required to clean up, the workspace selection dialog popped up and I could start eclipse normally again.
The -clean parameter is documented in the eclipse help
My problem was a corrupted workspace the solution was from Rob's link:
http://spacetech.dk/eclipse-failed-java-was-started-but-returned-exit-code-805306369.html
I started getting the same error "exit code = -805306369" just out of no where.
Eventually I looked at the Eclipse logs at the <workspace_directory>/.metadata/.log and realized that my Source Control plugin (Perforce in my case) was unable to connect and the eclipse was stuck.
This was because my eclipse was piggy back(depending) on the client connection that I have with my Perforce windows client and my Perforce client was not connected to the server. I connected my Perforce client and the eclipse started working normal.
this happens when mostly workspace is corrupted..... cooler solution is just to switch the workspace to safer location(new location).... and just import the project from previous workspace... princess can still be saved....
For me , Just change your Workspace to another one
I got this error, when workspace already setted up. Since the java virtual machine cannot be created. try command: java -version
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
I restarted my machine, and it solved my problem.
One of the class file in my project was corrupted. The name of a class file was too long and I was not able to delete or rename it, so I rename the folder containing it and then I was able to delete the project and that solved my problem.
Now i know that my workspace was corrupted, it solved my problem.
Go to your workspace and rename it.
Start your eclipse and by default it will create a workspace.
Go to File -> Switch Workspace, choose your original workspace.
I wasn't able to disable "Automatically find new updates and notify me." The option was not there on the Install/Updates page. Perhaps eclipse workbench has changed since that answer was written.
However, running eclipse with the -clean option in my old workspace did the trick for me. The way to do that in windows is to first find the directory where eclipse.exe lives. You can go to the start menu and in the "search menus and files" bar, type eclipse. You should see the purple globe icon pop up under "Programs." Hover your mouse over it and it will tell you the directory it exists in.
Then... open "computer" or some other window from the start menu and from there navigate to the window where eclipse is. Click your mouse in the bar at the top where the directory is displayed (somewhere not on the text). That directory will highlight. Now type cmd. A black command window will open and you will be in the directory where eclipse is. At the command prompt (drum roll) type eclipse.exe -clean
eclipse will start. Make sure it is asking to go to your corrupted workspace and click OK.
Wait for it and soon you will know if your workspace has been uncorrupted. Yay!
“java was started but returned exit code = -805306369” caused by Eclipse´s currupted workspace, I solved my problem with this 4 steps:
1) claose the eclipse.
2) Kill the adb from task manager.
3) Start your eclipse and by default it will create a workspace or start with new workspace.
4) Go to File -> Switch Workspace, choose your original workspace.
In my case, it is a work laptop, so pretty secure SOE
64 bit Win 7.
Unzipped Eclipse MARS onto a folder on "C" drive
Install failed consistently with Java error code -805306369
Created a separate folder on 'C' drive for workspace, granted
everyone full-control and that fixed it!!
I got same issue when opening files using shortcut - Ctrl+Shift+R.
I got it resolved by disabling "Automatic Updates".
Steps to disable automatic update in eclipse (helios): Windows >> Preference >> Install/Update >> Automatic Updates. Disable "Automatically find new updates and notify me".
How I managed to get mine working. I used a combination of the solutions above. It works for me.
Step 1: Change your workspace to some other names e.g. change it from workspace to workspace1.
Step 2: Access your eclipse and stop automatic updates (provided that you could access after changing your workspace)
Step 3: Exit your eclipse with workspace1
Step 4: Start your eclipse with former workspace by entering eclipse.exe -clean (if you are using others then use e.g. MuleStudio.exe -clean)
In conclusion, using a combination of solutions such as changing workspace, stop automatic updates and -clean work for me. Try it yourself.

How to setup libraries for IntelliJ 13 on Mac with JDK 1.8

I recently installed the Java 1.8 Update 20 JRE on my Mac running OSX 10.9.4. After that, I also added the JDK of 1.8.0_20. When I go into Terminal and execute "java -version" or "javac -version", each time I get "1.8.0_20" as a result. For me, this means that both JRE and JDK 1.8 are the System standard right now (I might be wrong on this).
So, I also add IntelliJ IDEA 13.1 and open it. I logged into GitHub using my credentials and it worked. So from the launcher window, I proceed Configure → Project Defaults → Project Structure. From here I firstly click the "New" button next to "No SDK" and select JDK. It automatically brings me to /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home. Just to make sure I select the JDK itself, I back off into ~/JavaVirtualMachines/ and select the jdk1.8.0_20.jdk, hitting return. This is now recognized as "1.8" in IntelliJ.
On the left hand side, I now go to Libraries and hit the "+" sign. This also automatically brings me to /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/jre/lib. I know that it has to add all the .jar files in this folder, so I highlight using SHIFT + CLICK the entire contents of the folder and click "Ok". This is now library "ext" (don't know where that name comes from). I click Apply and Ok and go back to the Quick Start menu.
Selecting "Create New Project", I leave the template for Java and see that the Project SDK has been set as 1.8 (Java version "1.8.0_20"). Underneath it gives me the option to tick for "Groovy" (again, no idea what that is) and lastly, the library... Only that the line "Use library:" returns "[No library specified]". Even when I tick Groovy and the library field becomes clickable, it still does not find the before-created Java library. Nevermind that, I untick Groovy and go to write some simple Java code: Under the project name, in its src folder, I create a class and write:
public class main {
public static void main (String[] args){
System.out.println("Hello World!");
}
}
When I try to run the code, the button for it is greyed out. I have been searching the SO forum for a while, but it doesn't seem that anyone on JDK8 and IntelliJ 13 had this exact problem. Any ideas?
Okay, I figured this out: Removed JDK 1.8 with its JRE for purpose of a clean install down the line.
Went into Eclipse and tried to run the same code with no trouble. So I opened IDEA and removed the JDK and lib that I added manually. Then, I inserted back the 1.7 JDK and left it as such. Opened a black project and did not tick Groovy or the library option. For some reason, IDEA now reads the JDK internal Lib and includes it in the project. Created a new "main" class and wrote the same code as above. Then I checked the run options and although 1 was greyed out, the other worked.
From then on I installed JDK 1.8 again and tried the same, everything works just fine now.

Categories

Resources