the console won't run the program. nothing i do works.
even when i'm trying to run the most simple program it still won't work and it always gives me the same error.
1. a pop up error window saying "Cannot connect to VM - Socket closed"
2. java.lang.module.FindException: Module guy not found
what can i do to solve the problem?
You first have to fix all compile errors to be able to launch it.
Currently, the code can not be compiled because try is a keyword in Java and therefore cannot be used as a variable name.
Related
I'm a beginner at programming and practicing Java (using MacOS and jdk.17) but have been instructed to use JShell to deal with smaller/snippets of Java code. I installed JShell, opened a text editor to create and compile a file called Intro.jsh with the code:
System.out.println("Hello! Please enter some text");
String x = System.console().readLine();
System.out.println("You wrote " + x);
I then opened terminal to set my working directory to ensure the file is saved in the same environment as the directory. I opened JShell and used the following command:
jshell> --execution local Intro.jsh
I receive error messages such as:
Error:
';' expected
--execution local Intro.jsh
^
Error:
not a statement
--execution local Intro.jsh
However, when I used the command /open Intro.jsh it shows:
"Hello! Please enter some text.
Exception java.lang.NullPointerException: Cannot invoke "java.io.Console.readLine()" because the return value of "java.lang.System.console()" is null at (#2:1)
You wrotenull"
The first line works however the second requires an input from user. Whilst I can open the file, I'm struggling to solve why I cannot execute despite double checking my wd before opening JShell.
I believe there's something I'm definitely missing out so hopefully should be a quick fix but due to limited computing experience I've tried researching for many hours but cannot seem to find out why.
Please let me know any solutions to this and any help will be greatly appreciated :)
See the JavaDoc for System::console!
It says: "Returns the unique Console object associated with the current Java virtual machine, if any." And further down, for the return value: "The system console, if any, otherwise null."
So System::console returns null when invoked inside JShell. Seems that there is no console available for the JVM that executes JShell. And to be honest, that will not surprise me much, although I have not tried it before.
JShell itself is running on that console, having a second console would not make much sense in this context.
i'm trying to launch the minecraft client using eclipse for Minecraft 1.8.9 mods, but when I try to launch client, I get:
'Launching Client' has encountered a problem.
Variable references empty selection: ${project_loc}
does anybody know what could be causing this or how to fix it?
edit: if It helps at all, i have created a github repo with my code here
edit #2:
I selected the correct folder as pointed out by a comment, but now It does this:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit
then in console it says:
Unrecognized option: -Xincgc
I'm just starting out with Scala and have been following its Getting Started instructions. The second part of the instruction involves pulling the hello-world template by running the sbt new scala/hello-world.g8 command.
My problem is that it keeps on giving me this error:
Error: Could not find or load main class Anne
Caused by: java.lang.ClassNotFoundException: Anne
I'd like to know the reason for this, as well as any possible fix I might use.
The following is my insight and attempts on fixing this problem.
Insight:
1. I might have a problem with java installation/scala/sbt installation that needs this class Anne since even with other sbt commands like sbt sbtVersion I get the same error
Attempts:
1. Change command to retrieve from full url:
sbt new https://github.com/scala/hello-world.g8
2.(Edit): Previously I thought the repository scala/hello-world.g8 did not exist and tried getting from other repositories with no luck and with the same error as above. However it was pointed out below that the repository actually exists in this url https://github.com/scala/hello-world.g8, thanks Dmytro Mitin.
I was looking into the incorrect account (sbt) instead of (scala)
(Edit): Day 2
3. Uninstall/Reinstall sbt -- still getting the error
4. Checked if java running properly by compiling sample code and running ( successful )
I was actually running the command in Visual Studio Code's bash terminal. I tried running it with cmd and everything's now working fine.
I have a script that opens with some code to start a connection to an Oracle database, however the code is crashing RStudio as soon as it runs. The exact code was run successfully on another machine previously.
The script opens by loading the required RJDBC package:
library("RJDBC", lib.loc="C:/R/library")
After, this I run the code below:
drv = JDBC("oracle.jdbc.OracleDriver", classPath="C:/R/ojdbc7.jar", identifier.quote = " ")
however this crashes Rstudio - there is no error statement, the program simply crashes stating that "R encountered a fatal error . The session was terminated." When I attempt run this at the command line in regular R (not RStudio) it crashes also.
If this is being caused by some conflict between R and machine, is there a way to determine what is causing it?
Thanks
I had exactly the same problem, having just upgraded my Java distribution from v6 to v8 (both Java Runtime and Java Developer Kit, running on Windows 7). I don't what the reason is, but after reinstalling v6 (and keeping v8), the problem was resolved.
In also encountered this problem but in my case the issue was that I had previously set JAVA_HOME in ~/.Renviron that did not match the version in place when rJava was installed. Simply removing JAVA_HOME was the fix in my case.
I was also experiencing the same sort of crash trying to connect to SQL Server.
Setting the JAVA_HOME variable as described https://www.r-bloggers.com/connecting-r-to-an-oracle-database-with-rjdbc/ the crashes went away:
Sys.setenv(JAVA_HOME='C:/Program Files/Java/jdk1.8.0_172')
library(RJDBC)
drv <- JDBC("com.microsoft.sqlserver.jdbc.SQLServerDriver",
"c:/Microsoft JDBC Driver 6.4 for SQL Server/sqljdbc_6.4/enu/mssql-jdbc-6.4.0.jre8.jar")
This is doing my head right in!
I am messing about with JRuby trying to make some Java calls. Here is the source Im messing with.
require 'java'
module JavaLang
include_package "java.lang"
end
module JavaSql
include_package 'java.sql'
end
begin
JavaLang::Class.forName("com.mysql.jdbc.Driver").newInstance
jdbcconnection = JavaSql::DriverManager.getConnection("jdbc:mysql://localhost:3306/accounts", 'root', '');
puts 'Werked'
rescue Exception => ex
connectmsg = "Could not connect to the database: " + ex.message;
puts connectmsg
end
I am using Netbeans 6.8 as the IDE.
When I run the script it all works fine and I get Werked printing out in the output.
When I try to run this through on the debugger I get
Could not connect to the database: java.lang.ClassNotFoundException: com/mysql/jdbc/Driver
Im sure its just something basic to do with setting a debugger configuration, but I can't find anything anywhere to give me a clue.
Why would the debugger not pick up these java classes?
Edit
Just to follow up, this is a bug in Netbeans 6.8. Here is the bug report.
Relieved that Im not going mad!
This seems like a general classpath issue. The fact that the reflection fails, supports this. Are you sure that your classpath is the same / similar to your runtime classpath?