eclipse terminates programs without an error - java

Eclipse has begun terminating any program I try to run before it does anything. The only output is 4.12 printed to the console. It's not just one program with errors, I've tried running old programs that I know worked before but they all exit with 4.12 being printed out.
I tried downloading a new version of eclipse (Mars.1 Release (4.5.1)) but it hasn't really done anything. In the old version it was exiting everything with the code 4.11 so I've run out of ideas to get this to work again.
EDIT
I'm on a mac, using 64-bit.
None of my programs run, I haven't just been leaving the main() empty.
I tried running from the command line and all my programs have changed type from .java to .class
The error I got in the command line was
Class names, 'HelloWorld', are only accepted if annotation processing is explicitly requested
The program running was just hello world.

Try to run your programs via command line, outside of Eclipse, just to make sure it's not an IDE configuration. If still your programs fail, try to re-install your JRE/JDK.
if still the problem occurs - provide us with the exact command line errors.

Related

Trying to run swiftlint through Java subprocess fails (works normally through command line)

I have a java program to run different kinds of linters, calling the linters as a process using ProcessBuilder. So far, other linters have worked for the most part but with swiftlint, i'm facing a strange issue
When I run it normally from the command line, with
swiftlint --enable-all-rules
It works perfectly, but executing the same through my Java subprocess utility
ProcessBuilder processBuilder = new ProcessBuilder("swfitlint", "--enable-all-rules");
Process process = processBuilder.start();
It fails with the following error message
SourceKittenFramework/library_wrapper.swift:31: Fatal error: Loading libsourcekitdInProc.so failed
At first glance it seems like for some reason certain libraries are not available to the java program which are available to when firing a command through bash, but just to be
sure, I tried running the following command through my subprocess util
swiftlint --version
swift --version
Both of which worked, meaning Java does have access to swift binaries installed on my machine. Any help would be appreciated.
I'm not still not entirely sure why this happens but i believe it's due to some kind of environment issue on my machine itself.
I tried running the same code inside of a docker container that uses the image built from the following base images
FROM openjdk:17-slim as java_base
FROM ghcr.io/realm/swiftlint:latest
COPY --from=java_base /usr/local/openjdk-17 /usr/local/openjdk-17
and it just worked

How can I run multiple threads in JOMP on Windows (10) from either the command prompt or in Eclipse?

I can't get multiple threads to run using JOMP no matter what I try. I actually can't run a JOMP program from the command line no matter what I try either in fact, although ironically it will compile from there and then run in Eclipse! Even in Eclipse though I only have one thread. I've been through the notes from my university course about installation of JOMP carefully, but they have not helped. I'll be more specific though:
Items in quotes below are from those notes:
"There are a couple of websites that tell you how to make jomp run under Eclipse, see http://www.lst.inf.ethz.ch/teaching/lectures/ss10/24/ assignments/assignment_10/eclipse.txt"
This refers to a now broken link. It also seem to be the only link anyone on forums like Stackoverflow refer to when talking about this issue. Apparently it has instructions on runtime settings for Eclipse to allow multiple threads to run, but since the link is currently broken I can't access those valuable instructions.
"All that is required in order to do that is to ensure that jomp1.0b.jar is on the CLASSPATH"
I ran echo %CLASSPATH% at the command prompt to check if it was on the class path and got the following response:
C:\Program Files\Java\jre1.8.0_162\lib\jomp1.0b.jar
On my PC the jomp jar file is in that folder, so it appears I should be able to execute compiled JOMP programs from the command line, but unfortunately that is not the case. By executing one of these commands it should run:
java −Djomp.threads=2 parallel
java −Djomp.threads=2 -cp . parallel
java −Djomp.threads=2 -cp C:\Users\terry\eclipse-workspace\JOMPHello\src parallel
This is the folder the jomp, java and compiled class files are in. I also checked if "parallel" is the fully qualified class name in the way I have set it up in Eclipse, and it does appears to be. So running one of these commands should allow me to run the jomp program from the command line as near as I can tell, but they all return the following error:
Error: Could not find or load main class parallel
Caused by: java.lang.ClassNotFoundException: parallel
(To which I feel like telling Java, "You're not looking hard it enough! It is right in the folder I am running this command from!")
Clearly I am missing something. Can anyone tell me how to get JOMP programs running on the command line, or alternatively knows where there are accessible instructions for how to set up the work around runtime settings in Eclipse?
My implementation of the program seems to run with only one thread, so hopefully that means it is correct, but I can only be sure once I have run it with at least a few more threads.
Thanks,
Terry.
I figured out how to set up the runtime argument in Eclipse. You just have to add the following line into the VM Arguments box in under the Argument tab in Run Configurations for the file:
−Djomp.threads=n
(where n as before is the number of threads you want).
I'd still like to know why it's not working on the Command Line though. It makes me think my Java is set up weirdly.

Readline support when running programs in Eclipse

I've just started using JLine for console input in my programs. In a bash shell, this works great. In the Eclipse Console view, nothing useful works - no history, no command completion.
Is there a way to get this working? (I'm on OSX in case that's relevant).
Note: I've looked at the Local Terminal plugin (https://code.google.com/p/elt/) and the TM Terminal (https://marketplace.eclipse.org/content/tm-terminal) but these both seem to be about running a general terminal, rather being used as a terminal for the programs I'm running. However, I may be missing something.

eclipse hangs when run application (application runs fine, eclipse is what hangs)

I have a single application which will cause eclipse itself to hang when run via eclipse. If I export this application as a jar and run it it works fine. But if I run (or debug) it the application will appear to start (according to ps) and run; but eclipse itself will hang, and is reported as a 'stopped' program with no CPU or memory usage. I've placed a breakpoints on the first line of this application and it doesn't even get there before eclipse ends up stopped. If I forcefully wake eclipse out of stopped state it will work; but it will also lose it's connection with the program I started. My program I want to debug will continue running but eclipse can't control or kill it after I resume the stopped eclipse.
I can run plenty of other applications without issue from eclipse. Oddly I had this issue before, then I could run my application for a day, and now I'm back to the original issue. I don't know what changed between those that would matter.
Can anyone suggest what may cause this or how to repair it?
UPDATE:
I did some more linux magic. It seems that eclipse is stopped while waiting for the command:
sh -c stty -lcanon min 1
It also seems that before that there was a sh (defunct) command which also hung without being reaped for a few minutes which I think was keeping eclipse from running properly; the sh (defunct) finally goes away if I wait long enough; but then the sh command I just linked comes up. I don't know what the original defunct SH command was; I can't do ps fast enough to catch it before it goes defunct. Both issues occur only with eclipse; as a jar file this program runs perfectly fine.
My running assumption is that eclipse isn't getting or handling the sigchild correctly? that would explain the sh (defunct) application at least. It doesn't explain the current SH command which doesn't show as defunct; despite it being something that should execute in seconds?
UPDATE 2.0:
I found this link: http://linux.about.com/od/srl_howto/a/hwtsrl13t04_3.htm basically stty is known to hang when it uses the < /dev/tty syntax; which is why the syntax is deprecated and replaced with a newer syntax. I'm pretty sure this is the problem. Sadly I have no way of figuring out what library is using the deprecated command. I think this all started with the ConsoleReader being constructed; but who knows what code actually ran the command that freezes? also, it seems if this was that broken anyone running consoleReader from eclipse on a linux environment would have the same problem; which I think is safe to assume isn't the case or it would be documented all over the net; so maybe my understanding is still off?
It is related to the configuration of the stty process that is created to attach the console and hence will occur only on UNIX like systems. Seems fixed on current 2.11 jline version.
To bypass the problem you can disable the special unix-terminal capabilities using:
-Djline.terminal=none
as VM argument on the eclipse launch configuration.
Try increasing -Xms<abc>m/-Xmx<efg>m (depending on the system memory) on eclipse.ini in the root directory of eclipse installation.
The problem was that we were using an older version of 'jline' which used deprecated functionality. The new jline jar fixed the problem, as it no longer used the deprecated stty calls. I'm not quite certain why eclipse caused this to happen every time; it seems as if it should be an intermittent error, but jline was definitely the cause.

Please help me get the java command to work

I'm learning how to make and run Java programs in Windows with Notepad and the command line. Right now I'm getting a well-known error when I try to run any sort of variant of java Main, Main being the starting class of the program, and I've done some research on it. The error is java.lang.NoClassDefFoundError, but any of the normal solutions for this error don't seem to be helping.
The program is in <root>\com\zork, and the classes are Main, Dungeon, and DungeonMaster, each in the package com.zork. They've all compiled just fine with the javac command, but attempting to run the program with java Main in either <root>\com\zork or just <root> keeps giving me the error above. I've tried many things with -cp, -classpath, and where I'm running java from. The current classpath is
<this directory doesn't matter>;.;"C:\Users\intprof\Desktop\ZORK in Java",
although the last entry has also been C:\Users\intprof\Desktop\ZORK in Java\com\zork, nonexistent, and a couple of other things.
What am I doing wrong? Thanks!
You need to run java com.zork.Main.

Categories