Sourcecode not found by Javac - windows - javac

I am new to java programming and I am learning the basics.
I am trying to use the java compiler (javac) via the windows Command Prompt for running a first "Hello World!" program. These are the steps I undertook:
1) I have created a file with Notepad with the following code:
public class Hello {
public static void main(String[] argumente) {
System.out.println("Hello World!");
}
}
2) I saved it as Hello.java in the following folders/ directories:
C:\Users\Ema\eclipse-workspace\classes
3) I opened the Windows 10 Command Prompt and inputted the following code:
C:\Users\Ema>javac -Xlint:all Hello.java
unfortunately I get this answer back when I "enter" the code line:
error: file not found: Hello.java
Usage: javac
use --help for a list of possible options
Could you please help me with some tips on how to run the program?
I have also already tried to give the targeted path via the javac -cp function, but I get always the same type of error.
Thank you in advance

Related

Substrate VM: Unable to launch the native image generator

I wanted to check out the mx image generator:
./mx image -cp $PWD/svmbuild -H:Class=HelloWorld -H:Name=helloworld
mx: unknown command 'image'
It seems that the "image" command is not available (anymore?)
Any replacement available?
Thanks
There's an mx native-image command.
The README file in the GraalVM project repository lists the following quick start snippet:
cd substratevm
mx build
echo "public class HelloWorld { public static void main(String[] args) {
System.out.println(\"Hello World\"); } }" > HelloWorld.java
$JAVA_HOME/bin/javac HelloWorld.java
mx native-image HelloWorld
./helloworld
Allegedly, one needs a JDK 8 with the JVMCI for this to work, here's a relevant quote from the README:
Install mx and point JAVA_HOME to a labsjdk.
For compilation native-image depends on the local toolchain, so make
sure: glibc-devel, zlib-devel (header files for the C library and
zlib) and gcc are available on your system.

error while reading extension file 'intellij_info_bundled.bzl'

we are trying to create a Scala project which uses Spark also but we are facing issue Encountered error while reading extension file 'intellij_info_bundled.bzl': no such package '#intellij_aspect//': No WORKSPACE file found in C:/users//_bazel_user/i45wuf6d/external/intellij_aspect. Is it has something missing in Intellij?
Scala file
package src.main.scala
object HelloWorld extends App {
def main(args: Array[String]) {
println("Hello, world!")
}
}
Build file
package(default_visibility = ["//visibility:public"])
load("#io_bazel_rules_scala//scala:scala.bzl", "scala_library", "scala_test")
scala_library(
name = "hello-world",
srcs = glob(["src/main/scala/*.scala"]),
)
scala_test(
name = "Hello_test",
srcs = glob(["src/main/scala/*.scala"]),
size = "small", # Expect this test to run quickly
)
Work Space
workspace(name = "scala_example")
rules_scala_version="7522c866450cf7810eda443e91ff44d2a2286ba1" # update this as needed
http_archive(
name = "io_bazel_rules_scala",
url = "https://github.com/bazelbuild/rules_scala/archive/%s.zip"%rules_scala_version,
type = "zip",
strip_prefix= "rules_scala-%s" % rules_scala_version
)
load("#io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")
scala_repositories()`enter code here`
# register default scala toolchain
load("#io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")
scala_register_toolchains()
Command and Error from console
Command: C:\ProgramData\chocolatey\bin\bazel.exe build --tool_tag=ijwb:IDEA:community --keep_going --curses=no --color=yes --experimental_ui=no --progress_in_terminal_title=no --aspects=#intellij_aspect//:intellij_info_bundled.bzl%intellij_info_aspect --override_repository=intellij_aspect=C:\Users\ADMIN.IdeaIC2017.3\config\plugins\ijwb\aspect --output_groups=intellij-compile-java,intellij-compile-py -- //...:all
INFO: Loading complete. Analyzing...
ERROR: Encountered error while reading extension file 'intellij_info_bundled.bzl': no such package '#intellij_aspect//': No WORKSPACE file found in C:/users/admin/appdata/local/temp/_bazel_sandhya/criyrv6d/external/intellij_aspect.
INFO: Found 3 targets...
WARNING: failed to create one or more convenience symlinks for prefix 'bazel-':
cannot create symbolic link bazel-out -> C:/users/admin/appdata/local/temp/_bazel_sandhya/criyrv6d/execroot/scala_example/bazel-out: Cannot create junction (name=C:\users\admin\scalaprojects\example1\bazel-out, target=C:\users\admin\appdata\local\temp_bazel_sandhya\criyrv6d\execroot\scala_example\bazel-out): ERROR: src/main/native/windows/file-jni.cc(86): nativeCreateJunction(C:\users\admin\scalaprojects\example1\bazel-out, C:\users\admin\appdata\local\temp_bazel_sandhya\criyrv6d\execroot\scala_example\bazel-out): ERROR: src/main/native/windows/file.cc(128): CreateJunction(\?\C:\users\admin\scalaprojects\example1\bazel-out): Cannot create a file when that file already exists.
cannot create symbolic link bazel-out -> C:/users/admin/appdata/local/temp/_bazel_sandhya/criyrv6d/execroot/scala_example/bazel-out: Cannot create junction (name=C:\users\admin\scalaprojects\example1\bazel-out, target=C:\users\admin\appdata\local\temp_bazel_sandhya\criyrv6d\execroot\scala_example\bazel-out): ERROR: src/main/native/windows/file-jni.cc(86): nativeCreateJunction(C:\users\admin\scalaprojects\example1\bazel-out, C:\users\admin\appdata\local\temp_bazel_sandhya\criyrv6d\execroot\scala_example\bazel-out): ERROR: src/main/native/windows/file.cc(128): CreateJunction(\?\C:\users\admin\scalaprojects\example1\bazel-out): Cannot create a file when that file already exists.
.
INFO: Building...
ERROR: command succeeded, but not all targets were analyzed.
INFO: Elapsed time: 18.108s, Critical Path: 0.05s
Make failed
This is a sample Helloworld program only
In general, like #Ittai, I would suggest you open an issue in the intellij plugin github repo.
Unfortunately, your version of the plugin is no longer supported. I, too, previously ran into an issue with an older version of the plugin and was recommended to upgrade to the latest version. Which resolved the specific issue I was facing.
When reporting the issue make sure to include the following bits of information:
intellij build number
plugin version number
rules_scala version
operating system (it seems your using Windows, while most users use unix based systems)
bazel release number
how you have opened the intellij project (BUILD file, WORKSPACE, .blazeproject)
Additionally, to verify this is in fact an issue with the plugin, I would also suggest you try to reproduce this issue on a Unix based system. It seems you are using Intellij
compile on Windows. This may be Windows specific issue with aspects not being recognized.
When attempting to reproduce, make sure to clone your repository in a separate directory, close the intellij project, and reopen the project

I am unable to use `ejabberd_auth` in my **helloworld** project

I am unable to use ejabberd_auth in my helloworld project.
-behaviour(ejabberd_auth).
...
....
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).
With that I get the error warning:
helloworld.erl:15: Warning: behaviour ejabberd_auth undefined
-import(ejabberd_auth, [try_register/3]).
...
....
try_register(<<"username">>, <<"example.com">>, <<"secret_password">>).
With this I get:
exception error: undefined function ejabberd_auth:try_register/3
Why am I unable to access ejabberd_auth?
I am using IntelliJ Idea, with the Erlang plugin installed.
Thank you all in advance.
UPDATE:
I'm on Ubuntu 16.04 LTS
I can get you past that error. Here's how...
When I compile a module in the erlang shell, the compiler creates a .beam file in the same directory, which allows me to call functions defined in the module. In your case, if you cd into the directory:
.../ejabberd/ebin
you will see all the ejabberd .beam files, including ejabberd_auth.beam. If you start an erlang shell in that directory, then issue your function call (don't compile anything), you won't get that error anymore.
But, then I get the error:
exception error: undefined function jid:nodeprep/1
in function ejabberd_auth:validate_credentials/3 (src/ejabberd_auth.erl, line 796)
in call from ejabberd_auth:try_register/3 (src/ejabberd_auth.erl, line`
There is no jid.beam file in that directory. But:
~/Downloads/ejabberd$ find . -name jid.beam
./deps/xmpp/ebin/jid.beam
You are going to have to figure out how to compile your module so that all the ejabberd modules are available to your program. See: ejabberd how to compile new module.
I am unable to use ejabberd_auth in my helloworld project.
Are you following a tutorial somewhere?

lcov struggles with folder structure under Windows

I've got problmes get lcov running smooth in a Windows 7 environmet.
I think there are problems with the folder structure of my project.
I have the following structure
D:\project\Filter_lib\Filter.c
D:\project\Filter_lib\Filter.h
D:\project\foo_lib\foo.c
D:\project\foo_lib\foo.h
D:\project\foo_lib\Test\foo_test.c
D:\project\foo_lib\Test\foo_test.h
Contents of the files:
Filter.h
uint32_t filter_1(void);
foo.h
void foo_init(void)
foo.c
#include foo.h
#include Filter.h
void foo_init(void)
{
...
}
static void foo_hadler(void)
{
...
}
foo_test.c
#include foo.c // Only known way to test static functions
static void test_foo_init(void)
{
... test cases;
}
I've compiled the whole thing with all the needed gcc options to produce a gcov output (gcna and gcno files)
When I try to run lcov I've got the following message:
geninfo.perl: WARNING: cannot find an entry for ^#^#Filer_lib#Filter.c.gcov in .gcno file, skipping file!"
I agree with geninfo that this file (^#^#Filer_lib#Filter.c.gcov) cannot be found in the .gcno file. In the .gcno file the correct include (..\Filter_lib\Filter.c) is mentioned.
I debuged the thing a bit and the file ^#^#Filer_lib#Filter.c.gcov is created with the correct content but I think the filename is later not recognized.
I already read the following thread: https://sourceforge.net/p/ltp/bugs/153/
But this workaround doesn't cover my cover.
Additional infos:
Compiler: MinGW32 installation in an actual version
Language: C
lcov: Version ported for Windows found on Github
Can anyone help me with this problem?
Thanks in advance.

Grails: How to know which command is being executed, from BuildConfig.groovy

Is it possible to know which command is being executed from the BuildConfig.groovy file, in order to change build config depending on the command? For example, if 'schema-export' then do not include 'Foo' library and so on?
I'm using Eclipse and I am running rails cmd from eclipse.
EDIT: after trying out Shashank solution I added details on the fact that I am using Eclipse.
By printing the 'sun.java.command' property I think that my Eclipse installation(Indigo Service Release 2 + Grails IDE 3.5 plugin) is rewriting the command launched to
org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.grails.ide.eclipse.longrunning.process.GrailsProcess --conf Y:\grails-2.4.4\/conf/groovy-starter.conf --classpath /C:/Program Files/eclipse/configuration/org.eclipse.osgi/bundles/1764/1/.cp/;/C:/Program Files/eclipse/configuration/org.eclipse.osgi/bundles/1766/1/.cp/ --is14
I looked upon it and yes, it is absolutely possible.
Inside anywhere in BuildConfig, you can write something like this:
String command = System.getProperty("sun.java.command")
if (command.contains("run-app")) {
compile (":hibernate:3.6.10.18") // example to install hibernate while running the app
} else if (command.contains("test-app")) {
compile (":hibernate:3.6.10.14") // some other version for test cases
}
Or for your example:
compile (":some-plugin:2.3") {
if (command.contains("export-schema")) {
excludes "foo"
}
}
That property will give you output like this:
org.codehaus.groovy.grails.cli.support.GrailsStarter --main org.codehaus.groovy.grails.cli.GrailsScriptRunner --conf /home/user/.gvm/grails/current/conf/groovy-starter.conf --classpath --offline run-app

Resources