|
I'm trying to follow Stanford's Intro to Programming course to learn Java. However, there seems to be a problem with their distribution of Eclipse for Windows (here), or perhaps it just doesn't work well with Windows 8. When I try to run that, I get this hideous mess of errors that I don't understand. Could someone help me get this working? I also tried using standard Eclipse, but couldn't get a Karel the Robot project working with it.
|
# ¿ Dec 18, 2013 17:55 |
|
|
# ¿ Apr 27, 2024 07:39 |
|
Zaphod42 posted:I don't have windows 8 so I don't know of its horrors, but you should be fine just using the normal Eclipse for Windows devs from the Eclipse page. Using the standard version of Eclipse, I followed the directions here to set up Karel with Eclipse. However, likely due to my brand-newness at Java, I couldn't figure out how to translate the importing and class setup for the program written in the second lecture into something that would work with the directions I linked above.
|
# ¿ Dec 18, 2013 19:05 |
|
Zaphod42 posted:That seems fine. If you've got the libraries imported, the 'second lecture program' you refer to should work. Namespaces are set up such that it shouldn't be machine specific. I think my problem lies in importing. Currently, my project hierarchy is code:
code:
hooah fucked around with this message at 20:13 on Dec 18, 2013 |
# ¿ Dec 18, 2013 20:09 |
|
Jabor posted:You don't need to import the .jar file - instead, you import the specific classes you want to use, and Eclipse uses your classpath setup to figure out where they are. The fixes I'm offered are "Create class 'Karel'", "Change to 'Kernel' (java.awt.image)", and "Fix project setup...", none of which does what you say.
|
# ¿ Dec 19, 2013 01:21 |
|
rhag posted:you will want to choose fix project setup, and add that jar onto the project's classpath. then you will have it available. Could you go into a little more detail? Keep in mind I've never worked with java or Eclipse before. Here's the dialog I see when I choose fix project:
|
# ¿ Dec 19, 2013 03:18 |
|
Alright, I got the import working (turns out I had to import "kareltherobot", not add any external stuff), but I can't figure out the right name to extend. I've tried Karel, KarelJRobot, and kareltherobot. Here's my project directory:
|
# ¿ Dec 19, 2013 14:35 |
|
Woodsy Owl posted:You've got to import the package by it's package name and follow it by a .* or a specific class. For example: Yeah, import kareltherobot.*; is what I did.
|
# ¿ Dec 19, 2013 14:50 |
|
Woodsy Owl posted:What's the error that you're receiving? I have a line that says public class OurKarelProgram extends kareltherobot{. The problem is that I can't figure out what to put after extends that will satisfy Eclipse. Anything I put there gets underlined, and the mouse-over pop-up says "[whatever] cannot be resolved to a type". I've tried Karel, KarelJRobot, and kareltherobot.
|
# ¿ Dec 19, 2013 15:14 |
|
Woodsy Owl posted:Oh okay. The keyword 'extends' makes your class an extension of the particular class. So, the 'extends' keyword needs to be followed by a class, not a package. What it means is that your class becomes an extension of the class; your class has the same methods and constructors as the extended class, and you can add your own methods to your class to 'extend' the method. That helps conceptually, but not really specifically, since evidently the Karel distribution I grabbed isn't quite the same as the one used in the Stanford lectures, so I don't know which class I should be extending. Hmm. As an aside, do you need the this. in a method, or can you leave the data member naked as in C++?
|
# ¿ Dec 19, 2013 15:33 |
|
Zaphod42 posted:Here's a page I found on Karel for java I'm not sure if it's the same library. The one I got was from Pace University; the link from that Java tutorial is dead. The first thing I tried doing while watching the lecture video was saying import standford.karel.*;, and Eclipse couldn't resolve the stanford import. I used the contact link on the Stanford site to ask if there's somewhere to download the Karel project or if they could make heads or tails of the error their Eclipse distro was giving me, but based on their automated response, I'm not hopeful.
|
# ¿ Dec 19, 2013 17:34 |
|
Zaphod42 posted:I'm confused. You said you were doing Stanford's intro to programming course. Stanford sent you to Pace? I'm doing Stanford's free online course, yes. They didn't provide any sort of Karel anything, so I went looking for something to grab, and found the Pace one. Since it looks like the Stanford course isn't going to work (at least not the first however many lectures until he moves on past Karel), what tutorials do you recommend? I'm looking to learn Java between semesters so I can go into my second semester with a little more of a varied background than just C++.
|
# ¿ Dec 19, 2013 20:19 |
|
Woodsy Owl posted:If you've got a bit of a background in programming already (it sounds like you've done some C++) then I would suggest you work through the beginning of the official Oracle Java Tutorials. I would suggest you start at Lesson: Language Basics so you can see how Java syntax differs from C++. Thanks. I also grabbed the videos mentioned in the OP.
|
# ¿ Dec 20, 2013 13:34 |
|
greenchair posted:So Ive made a program in eclipse that I kind of like, and I'd like to be able to run it without opening the project in eclipse and then compiling and running it from there. How do I make it into an actual program that I just double click on and then it opens and runs? I believe you can export it as a jar, which should be runnable on its own. However, the only Java stuff I've done is the tutorial videos hosted on Sourceforge that are in the OP, so take that as you will.
|
# ¿ Jan 12, 2014 03:28 |
|
I'd like to spend some time this summer learning Java. I've had three semesters working with C++ so far, but no other languages. I did the short series of tutorial videos that could be grabbed from Sourceforge, but I'd like a full book to really dig into the language. Any recommendations?
|
# ¿ Apr 21, 2014 02:36 |
|
I'm going through the Java Trails, and for the Exercises here, I'm having a little trouble. Here's my PlayingCard class:Java code:
Java code:
Java code:
What's wrong with my solution? It appears that the error happens when it tries to add the first card, but the solution seems to do something similar: Java code:
|
# ¿ May 7, 2014 01:56 |
|
Ah, I see. Thanks, guys. I made a mental note when I read about initializing stuff that it's different than C++, but I didn't really take that to heart.
|
# ¿ May 7, 2014 02:44 |
|
Zaphod42 posted:You still have to call new in C++ or malloc in C so its not really different... the syntax for declaring the array is just slightly different, I guess I see what you mean. What? You generally don't, unless you want to instantiate something on the heap. Creation of, say, a string on the stack is just string myString = "whatever";. Unless you were implicitly talking about using the heap. Speaking of, does Java use the heap for all non-primitive types?
|
# ¿ May 10, 2014 12:12 |
|
Zaphod42 posted:We were explicitly talking about arrays. Yeah, I guess we were. Thanks for the expansion.
|
# ¿ May 12, 2014 22:02 |
|
baka kaba posted:This is probably the most 'no poo poo' thing ever but I was learning some Eclipse keyboard shortcuts the other day (we all have our hobbies) and I found out about Alt+\ Did you mean Alt+/? I searched the first few web pages that came up in a search for "Eclipse keyboard shortcuts", and none of them had Alt+\.
|
# ¿ Jul 14, 2014 01:08 |
|
I'm trying to go through the Udacity "Developing Android Apps" course. I'm primarily a C++ guy, but I did take a short MOOC on Java late in the summer. However, I'm stuck on a particular step. There's a class which extends Fragment and has some network code in it. The step is to move it to another file, then create a nested class that extends AsyncTask. In there, I have to create a method that overrides doInBackground. So, here's what I've got for the nested class:Java code:
|
# ¿ Dec 17, 2014 02:25 |
|
Ok, I changed the inheritance to public class FetchWeatherTask extends AsyncTask<String, Void, Void>, but I don't understand what I need to change in the function signature. I thought (Params... params) meant that you could have a variable number of parameters, all of the same type. Since I put String as the Params generic, why doesn't String something work as the parameter for doInBackground?
|
# ¿ Dec 17, 2014 14:58 |
|
Great, that did it! Now I know about an array of parameters in Java.
|
# ¿ Dec 17, 2014 15:41 |
|
Oops, missed that Android Studio is now complaining about a missing return statement for protected Void doInBackground(String... params). Why is that?
|
# ¿ Dec 17, 2014 17:49 |
|
carry on then posted:Lowercase v. Void is not a reserved word so it's expecting a Void object to be returned. Ah, ok. Sorry I'm stupid; Java's my first second language, so I get tripped up on little differences like what's capitalized. Or not. I did that for the method signature, but then it complains on the signature about attempting to use an incompatible return type. I changed the generics to lower-case void, and that made the signature fine, but now I get an error on the inheritance line with the voids saying they're an illegal type. hooah fucked around with this message at 18:05 on Dec 17, 2014 |
# ¿ Dec 17, 2014 18:03 |
|
Right, I tried that:Java code:
|
# ¿ Dec 17, 2014 19:10 |
|
Oh, fantastic, return null; worked. That is some weird workaround poo poo, you ain't kidding. Thank you! Now I can continue to shoehorn Java learning in as I do this Android app course.
|
# ¿ Dec 17, 2014 19:23 |
|
I'm trying to build and run jMAVSim. When I tried to build the project in IntellliJ IDEA under Java 1.8.0_31, I get these errors:quote:F:\jMAVSim\jMAVlib\src\me\drton\jmavlib\conversion\RotationConversion.java I tried "fixing" what the IDE didn't like by changing, adding (existing objects), or removing arguments and in one case changing an import statement ("import org.la4j.matrix.Matrix;" to "import org.la4j.Matrix;"). That allowed the project to build, but I can't find the jar file anywhere. First of all, were the changes I made appropriate? If not, what should have been done? If I'm ok through the build step, what do I need to do to generate a jar file?
|
# ¿ Mar 8, 2015 20:05 |
|
Sedro posted:Did you git clone --recurse-submodules ? I did not, since I didn't know about that command. Did that and ant ran fine. However, I can't run it; when I try from the command line I get the message "Could not find or load main class". hooah fucked around with this message at 00:41 on Mar 9, 2015 |
# ¿ Mar 9, 2015 00:38 |
|
How the hell do I get a jar GUI to actually be responsive when I run it on Windows 8.1? I didn't make the file, so I can't really edit it (Stanford's NER tagger, for the record). It starts up OK and I can click a menu, but as soon as it opens that menu, nothing else responds except the close button.
|
# ¿ Apr 30, 2015 15:33 |
|
Yeah, I can run it fine on the school's server (Windows Server 2012, I believe).
|
# ¿ Apr 30, 2015 15:44 |
|
carry on then posted:You could try launching it from the command line and seeing what gets printed when you click the menu, that might give you some insight. Nothing is printed. It seems to fork the command, since the prompt looks ready to accept another command. quote:Other than that the only thing to check is that you have the right version of the JRE (I see the software you're using requires Java 8,) and that you have the latest updates for it from Oracle. java -version returns 1.8.0_45, which is Java 8, correct? quote:Also, it's kind of a one-in-a-million chance, but why not try deleting your copy and redownloading it? Occasionally things do get corrupted which is why some people provide the MD5 hash of their binaries so you can be absolutely sure no bits got flipped. I tried this, too, and no luck.
|
# ¿ Apr 30, 2015 21:33 |
|
Zaphod42 posted:Can you run other Java JARs okay? Something sounds wrong with your JRE. I'm not sure; I don't think I have any other JARs just sitting around. Do you have an example?
|
# ¿ Apr 30, 2015 22:14 |
|
That works fine until I open a secondary dialog. The Open dialog box was completely empty and unresponsive, and the rest of the program was unresponsive after closing that window. I tried Options, which I was able to see the first time I tried it, but just tried again and got a blank window. Sounds like my JRE is hosed up, but I feel like I've reinstalled it in the past for this same problem. Is there a good set of instructions for "really, do a full clean uninstall" reinstallation anywhere?
|
# ¿ Apr 30, 2015 23:11 |
|
Just reinstalled, similar behavior, but I see the content of secondary windows more often.
|
# ¿ Apr 30, 2015 23:19 |
|
hooah posted:Just reinstalled, similar behavior, but I see the content of secondary windows more often. No further suggestions to make JARs run properly?
|
# ¿ May 4, 2015 00:59 |
|
carry on then posted:It's pretty clear at this point that you've got something wrong with your JRE or underlying operating system. I mean, you could download the source for that Portecle and try to run it and see what's happening when it freezes, but at this point I'd start looking for alternate ways to use the software (a VM, maybe? Or if your school offers a remote desktop session, just use that for your assignment.) Unfortunately, you may not be able to see a full resolution of the problem without reinstalling your OS. Yeah, I ended up running the thing over RDP to a school machine. loving Java.
|
# ¿ May 5, 2015 17:04 |
|
Alright, I'll try to give more detail. I did use Revo when I uninstalled the existing Java. However, when I reinstalled, the installer found an installation of Java 7 that Revo was apparently unaware of. The Java installer removed the outdated version, then installed the new one. I am still unable to have a JAR GUI (either the Stanford NER program or the previously-mentioned portecle) be responsive beyond one mouse click. I'm sorry if I haven't satisfied your specificity requirements; I'm pretty busy at the end of the semester, and don't currently have a lot of time for super-detailed troubleshooting. I was just responding to what was asked.
|
# ¿ May 5, 2015 20:43 |
|
Sedro posted:Get a JVM stack dump using jstack or jvisualvm Ok, here's the stack dump from jstack: pre:Attaching to remote server Files\Java\jdk1.8.0_31\bin\jstack.exe 1390464, please wait... Error attaching to remote server: java.net.MalformedURLException: invalid URL String: //Files\Java\jdk1.8.0_31\bin\jstac k.exe 1390464/SARemoteDebugger sun.jvm.hotspot.debugger.DebuggerException: java.net.MalformedURLException: invalid URL String: //Files\Java\jdk1.8.0_31 \bin\jstack.exe 1390464/SARemoteDebugger at sun.jvm.hotspot.RMIHelper.lookup(RMIHelper.java:115) at sun.jvm.hotspot.HotSpotAgent.connectRemoteDebugger(HotSpotAgent.java:517) at sun.jvm.hotspot.HotSpotAgent.setupDebugger(HotSpotAgent.java:374) at sun.jvm.hotspot.HotSpotAgent.go(HotSpotAgent.java:304) at sun.jvm.hotspot.HotSpotAgent.attach(HotSpotAgent.java:183) at sun.jvm.hotspot.tools.Tool.start(Tool.java:196) at sun.jvm.hotspot.tools.Tool.execute(Tool.java:118) at sun.jvm.hotspot.tools.JStack.main(JStack.java:92) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at sun.tools.jstack.JStack.runJStackTool(JStack.java:140) at sun.tools.jstack.JStack.main(JStack.java:106) Caused by: java.net.MalformedURLException: invalid URL String: //Files\Java\jdk1.8.0_31\bin\jstack.exe 1390464/SARemote Debugger at java.rmi.Naming.parseURL(Naming.java:243) at java.rmi.Naming.lookup(Naming.java:96) at sun.jvm.hotspot.RMIHelper.lookup(RMIHelper.java:113) ... 13 more Caused by: java.net.URISyntaxException: Illegal character in authority at index 2: //Files\Java\jdk1.8.0_31\bin\jstack.e xe 1390464/SARemoteDebugger at java.net.URI$Parser.fail(URI.java:2848) at java.net.URI$Parser.parseAuthority(URI.java:3186) at java.net.URI$Parser.parseHierarchical(URI.java:3097) at java.net.URI$Parser.parse(URI.java:3063) at java.net.URI.<init>(URI.java:588) at java.rmi.Naming.intParseURL(Naming.java:273) at java.rmi.Naming.parseURL(Naming.java:237) ... 15 more
|
# ¿ May 9, 2015 12:53 |
|
Jabor posted:This looks wonky. What did you type into the command prompt to actually run jstack? After changing to the jdk \bin directory, "jstack.exe [PID]". I had done that after clicking on a menu. Here's a dump from just after starting the jar: pre:C:\Program Files\Java\jdk1.8.0_31\bin>jstack.exe 1394468 2015-05-09 08:19:39 Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode): "D3D Screen Updater" #22 daemon prio=7 os_prio=1 tid=0x0000000018840000 nid=0x154520 in Obj 0] java.lang.Thread.State: TIMED_WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000e15e7fb8> (a java.lang.Object) at sun.java2d.d3d.D3DScreenUpdateManager.run(Unknown Source) - locked <0x00000000e15e7fb8> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) "TimerQueue" #20 daemon prio=5 os_prio=0 tid=0x00000000187b5800 nid=0x1545cc waiting on con java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000e15e0a80> (a java.util.concurrent.locks.AbstractQ ject) at java.util.concurrent.locks.LockSupport.park(Unknown Source) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unkn at java.util.concurrent.DelayQueue.take(Unknown Source) at javax.swing.TimerQueue.run(Unknown Source) at java.lang.Thread.run(Unknown Source) "Swing-Shell" #18 daemon prio=6 os_prio=0 tid=0x0000000018721000 nid=0x1547b8 waiting on co java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000e1394df0> (a java.util.concurrent.locks.AbstractQ ject) at java.util.concurrent.locks.LockSupport.park(Unknown Source) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unkn at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at sun.awt.shell.Win32ShellFolderManager2$ComInvoker$3.run(Unknown Source) at java.lang.Thread.run(Unknown Source) "DestroyJavaVM" #15 prio=5 os_prio=0 tid=0x0000000001e30800 nid=0x15478c waiting on conditi java.lang.Thread.State: RUNNABLE "AWT-EventQueue-0" #14 prio=6 os_prio=0 tid=0x0000000017368000 nid=0x154240 waiting on cond java.lang.Thread.State: WAITING (parking) at sun.misc.Unsafe.park(Native Method) - parking to wait for <0x00000000e0ff5c10> (a java.util.concurrent.locks.AbstractQ ject) at java.util.concurrent.locks.LockSupport.park(Unknown Source) at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unkn at java.awt.EventQueue.getNextEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) "AWT-Windows" #12 daemon prio=6 os_prio=0 tid=0x0000000017367800 nid=0x1545f4 runnable [0x0 java.lang.Thread.State: RUNNABLE at sun.awt.windows.WToolkit.eventLoop(Native Method) at sun.awt.windows.WToolkit.run(Unknown Source) at java.lang.Thread.run(Unknown Source) "AWT-Shutdown" #11 prio=5 os_prio=0 tid=0x000000001730f000 nid=0x1545f8 in Object.wait() [0 java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000e0ff2050> (a java.lang.Object) at java.lang.Object.wait(Unknown Source) at sun.awt.AWTAutoShutdown.run(Unknown Source) - locked <0x00000000e0ff2050> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) "Java2D Disposer" #10 daemon prio=10 os_prio=2 tid=0x000000001730e800 nid=0x1509b8 in Objec java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000e0fec898> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x00000000e0fec898> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at sun.java2d.Disposer.run(Unknown Source) at java.lang.Thread.run(Unknown Source) "Service Thread" #9 daemon prio=9 os_prio=0 tid=0x00000000157ce800 nid=0x1543f8 runnable [0 java.lang.Thread.State: RUNNABLE "C1 CompilerThread2" #8 daemon prio=9 os_prio=2 tid=0x0000000015772800 nid=0x154408 waiting 0000] java.lang.Thread.State: RUNNABLE "C2 CompilerThread1" #7 daemon prio=9 os_prio=2 tid=0x0000000015771800 nid=0x154040 waiting 0000] java.lang.Thread.State: RUNNABLE "C2 CompilerThread0" #6 daemon prio=9 os_prio=2 tid=0x000000001576c800 nid=0x153dcc waiting 0000] java.lang.Thread.State: RUNNABLE "Attach Listener" #5 daemon prio=5 os_prio=2 tid=0x000000001576a800 nid=0x1547ac waiting on 0] java.lang.Thread.State: RUNNABLE "Signal Dispatcher" #4 daemon prio=9 os_prio=2 tid=0x0000000015769000 nid=0x1544b8 runnable java.lang.Thread.State: RUNNABLE "Finalizer" #3 daemon prio=8 os_prio=1 tid=0x0000000001f25800 nid=0x154780 in Object.wait() java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000e0c06f58> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) - locked <0x00000000e0c06f58> (a java.lang.ref.ReferenceQueue$Lock) at java.lang.ref.ReferenceQueue.remove(Unknown Source) at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source) "Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x0000000001f1d000 nid=0x1547c0 in Obje ] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000000e0c06998> (a java.lang.ref.Reference$Lock) at java.lang.Object.wait(Unknown Source) at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source) - locked <0x00000000e0c06998> (a java.lang.ref.Reference$Lock) "VM Thread" os_prio=2 tid=0x0000000015737800 nid=0x154410 runnable "GC task thread#0 (ParallelGC)" os_prio=0 tid=0x0000000001e46800 nid=0x154790 runnable "GC task thread#1 (ParallelGC)" os_prio=0 tid=0x0000000001e48000 nid=0x15476c runnable "GC task thread#2 (ParallelGC)" os_prio=0 tid=0x0000000001e4a000 nid=0x154788 runnable "GC task thread#3 (ParallelGC)" os_prio=0 tid=0x0000000001e4c000 nid=0x1547c4 runnable "VM Periodic Task Thread" os_prio=2 tid=0x000000001701d800 nid=0x154008 waiting on conditio JNI global references: 489
|
# ¿ May 9, 2015 13:21 |
|
|
# ¿ Apr 27, 2024 07:39 |
|
Sure, but first, one thing that I'm unsure about is the process ID. I used Task Manager to get it, but all I could find was a PID for java.exe. Should that be the correct PID, or should I look for a different one?
|
# ¿ May 9, 2015 13:39 |