Problem in running Stanford assignment on eclipse - java

I am new learner of public sources of Stanford cs106a. I got sucked when run my assignment1. You can download it from here:
https://see.stanford.edu/materials/icspmcs106a/Assignment1.zip
I suppose to see the image on the following file after press run on Stanford menu and choose CollectNewspaperKarel code.
https://see.stanford.edu/materials/icspmcs106a/07-assignment-1-karel.pdf
But there is no any Karel or his world. I didn’t get any error. I am running eclipse 2018-9 and my JDK version is 11.0.1 on macOS Sierra 10.12.3. I added the Stanford plugin as well. I do the following instruction for installing eclipse and the plugin:
https://web.stanford.edu/dept/cs_edu/eclipse/
How should I solve my problem to see Karel at result window after run assignment?
P.S. My English isn't good actually!

I also had a same problem with those files.
The Assignment1.zip file seems working with the Java 6 runtime only.
You can still run it by downloading the legacy Java 6 runtime here and install it.
https://support.apple.com/kb/DL1572?locale=en_US
Then you need to configure to use the runtime.
Preference -> Java -> Installed JREs
Click Search
Select /Library/Java/JavaVirtualMachines/1.6.0.jdk
Check it
Preference -> Java -> Compiler
Select 1.6
However, I actually found newer assignments files which work with the updated Java runtime.
https://web.stanford.edu/class/archive/cs/cs106a/cs106a.1178/
If you follow the Eclipse link, there are instructions to setup it.
You can also find each assignment page links.
For example, find Assignment 1: Karel the Robot on the above page and follow the assignment page link below.
Find Click here to redownload the starter code if you have already completed the Honor Code form.
You can download CS106A-Assignment1.zip which works with the updated Java runtime.

Related

How can I set the path to my Java decompiler in VSCode

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.

Karel the Robot is empty using IntelliJ IDEA 15.0.2

I have downloaded and installed the latest version of Java JDK (both version X86 and X64) [as Stanford tutorial said].
As of writing the latest version is 8u66
But still the program doesn't show up anything. I don't like eclipse and I'm pretty sure that somehow this program works on IntelliJ too. I've done the steps below:
1. File -> New -> Project from Existing Source -> Assignment1
2. paste the following code into the CollectNewspaperKarel.java
public static void main(String[] args) {
stanford.karel.Karel.main(new String[] { "code="
+ StoneMasonKarel.class.getCanonicalName() });
}
public void run() {
}
and clicked on run. the programs runs perfectly but nothing doesn't show up.
IntelliJ IDEA IMAGE,
I have searched a lot, and a lot of people said we should have JRE/JDK1.6 but on Stanford website is "Before installing Eclipse, you will first need to have a copy of the latest version of the Java JRE (Java Runtime Environment) installed on your computer. Note that Java version 1.8 is the latest version of Java."
So I assume this program should work on latest version of java too not only on 1.6
OS: Windows 10 X64 | JAVA: jdk-8u66 (both X64 and X86) | IntelliJ IDEA: v.15.0.2
https://web.stanford.edu/class/cs106a/software/index.html
I am going through courses on SEE. I also had the blank Java window when I ran a java file from the Assignments download.
I was able to get them to run in JDK 1.8 using the standard Eclipse.
Here's what I did...
There is a Stanford Eclipse plug-in. I found instructions for that at https://web.stanford.edu/class/archive/cs/cs106a/cs106a.1178/eclipse/. Under the installation instructions for Mac or Windows, whichever you use, there is a link to the Stanford plug-in.
Then go to https://web.stanford.edu/class/archive/cs/cs106a/cs106a.1178//resources/ and download, unzip and import into Eclipse the BlankKarelProject.zip file.
Now, I don't know a lot of stuff. But when I imported that Blank one and ran that java file, I got a blank world to load. Then in that java application window, I clicked the Load World button. A file window opened up and I navigated to the file on my local disc the world named "CollectNewspaperKarel" and then I see what the world is supposed to look like for that assignment.
I notice for the imported Assignment file there is no src or lib dirs. My best guess is I can work on/edit the assignment in the respective assignment's java file then copy paste it into the BlankKarel.java file, run, see it happen in the world I selected.

How to run Java code on Eclipse Juno

I'm learning Java and using Eclipse as main IDE right now, but i can't run Java code from it (There are no Run as or Debug option in the Popup menu).
And personally, i don't to use 2 difference version of Eclipse.
Thanks
Edit : I'm using Eclipse Standard 4.3 and it doesn't have run as \ Java Application 's option. It only exists in Eclipse IDE for Java Developers.
This is not the same version of Eclipse but the button is identical.
#illunara , I am using Juno since a long time now. You can run the program using one of the following way and it's pretty simple where is your confusion ??
1) refer to the following screen shot : You can right click on the java project you will see the run as option and from there you can choose on of the option to run as java application
2) You can go to run-> run as-> java application
3) you can right click the mouse on a java program and you can run from their too.
================================================================================================
EDIT
Just as you mentioned you have eclipse standard so you need to add the JDT plugins before you do the above. you can find more details at the following site :
http://www.eclipse.org/jdt/overview.php
Hope this is helpful.

Unable to run Java program in Eclipse Juno 4.2

I reinstall my Eclipse environment every year when the new version is released. The most recent release - Juno - however, does not work as expected.
Currently, when I try running demos from Oracle, for example, it asks me to select an Ant file to run before compiling. After creating a blank Ant file to bypass the requirement (which I thought was rather dumb, since I don't think TDD is something that should be forced on people), it still refused to run, saying the "Selection could not be launched."
I understand that Juno is an update from the 3.x track to the 4.x track, but this seems a little ridiculous to me. What can or should I do so I can get Eclipse back up and running again?
Just to clarify:
All files in question are on my Eclipse workspace path
I don't do much in the way of Java development, though I know I'll need to do so soon. Hence, my unfamiliarity with the most recent version of Eclipse.
I would like to run my files & projects without Ant files. I know it has something to do with Run configs, but I don't know how to change them.
Here's what I did to run the demo from Eclipse Juno:
Downloaded the project from http://docs.oracle.com/javase/tutorial/uiswing/examples/zipfiles/components-FrameDemoProject.zip (if this is not the correct demo, then please provide the link you're using)
Unzipped it to my projects directory (not my workspace), so that you have:
PROJECTS_DIR/components-FrameDemoProject/src
PROJECTS_DIR/components-FrameDemoProject/nbproject
PROJECTS_DIR/components-FrameDemoProject/build.xml
From Eclipse, File > New > Java Project
List item Uncheck Use default location and navigate to <PROJECTS_DIR>/components-FrameDemoProject
Hit Finish
Drill down to src/components/FrameDemo.java
Right-click on FrameDemo.java and select Run As > Java Application
Let me know if any of these steps give you trouble.
Take a look at you project properties and select the Builders entry. Do you see an Ant Builder entry? Try to select or create a Java Builder entry instead.
I just created a new Java Project in Juno and added the FrameDemo.java source. In my case, the Java Builder was selected as the default for this new project.

Thinking in java library installation

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.

Categories