Scala - java.exe accessing internet? - java

Hm, so I set up Scala in order to start learning it.
When I compile a .scala script, though (i.e. "scala whatever.scala" in the terminal), java.exe is accessing the internet?
Why? Is that intended behaviour or did I forget to configure something?
The script I run was fairly simple, if that should matter:
args.forall(println)

It seems to me that Scala compilation happens inside a Java JVM. So when you compile Scala, the java command is executed.
Java JRE has a mecanism to update itself. When a new version is out, it asks the users (at least on windows?) if they want to install the new version.
It is possible that everytime a java command is launched, it checks for updates (?)
Edit: it is possible that this is because in some cases you are using a "compile server" for Scala. This means an extra JVM is spawned just for compilation and is kept alive after your initial compilation. Then next compilation will be faster because the compilation server will already have been started and all the classes will be loaded.
It is possible that a client JVM is communicating to the compilation server JVM by using a network protocol.
Check some links:
http://blog.jetbrains.com/scala/2012/12/28/a-new-way-to-compile/
https://github.com/typesafehub/zinc

Related

SVN pre-commit hook for java code compilation

This sounds to me difficult but ensuring, if it is possible to add server or local svn pre-commit hook to prevent if there are any java code compilations. Usually when there is a requirement to merge bulk of java files from higher version to lower version, and if we do not have working local lower env setup, then this mechanism will help to save time setting up the local env.
Just thinking a solution - If I have a running QA AIX box of lower env, that I can utilize for code compilation while doing the checkins, in the hook I can add command as javac -classpath <AIX path>:$CLASSPATH:<corresponding jar> -d . filename.java, where filename.java will be passed as parameter. Along with connection credentials so that I can first connect to AIX before to compile. Is this approach possible, if yes how to add such conditions in hook. Or is there any thing already available that I am not aware of ?

jvm forking duplicate child sporadically

I have one java application which is forking child JVM for doing some execution. Child process looks same like parent one including all arguments.
TO confirm the parent, i verified parent Id and its always original JVM.
Application is running as plain java process i.e. not in any server like apache, weblogic etc.
As processes have same args, both are writing to same log files and open files are too same.
This is new behaviour which was not present earlier. Could someone provide clue around what to check to find cause
JVM version:- OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.14.04.1)
OS: Ubuntu 14.04
One possibility is an explicit call to Runtime exec method.
Something like the following:
Process process = Runtime.getRuntime ().exec("java -jar myApp.jar");
This will create a new process child of the main process.
This can be done explicitly (with the previous code) or implicitly calling some external library that for example start a new process depending on some configuration file.
We were calling tar via Processbuilder which was getting hang at forkAndExec. Fork was successful , so could see java process but not exec. its getting hang at close syscall for major time due to high number of Disk Operations.

Internal error in eclipse when running java program

Eclipse froze on me earlier today, so I typed "top" into the command prompt and killed it. Now when I try to run a java application, I get this error:
eclipse\plugins\org.eclipse.jdt.debug_3.7.0.v20110509
That's all that shows up under details.
None of my previously working programs run, and I have no clue what this is. I have Eclipse 1.5.0 running 1.6 and 1.7 Java, depending on what program. Thanks for any help.
It is possible that you killed part of the process but not all of it. It is possible that a java process is running with a reference to this job. I would try restarting your computer to see if it will stop whatever process is referencing that jar.
Aside from a restart, then another option would be to use (in linux) pstree, filtered for your user to see if any other jobs are referencing that jar and/or java.
EDIT:
Another path is to look at log files. On linux they are in /var/log. Here's a link in that direction: http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/felog.html

java jni Exception Access Violation

My java application which uses JNI is crashing with hs_err_pid file giving the error as "Exception Access Violation". The OS is Windows VISTA.
From what I know, my native code is illegally writing to some chunk of memory that does not belong to it.
I have used valgrind on Linux on pure native code to detect such problems in the past.
But when using java, valgrind simply fails and does not work.
What (if any) method would you suggest to identify the offending piece of code?
It is not possible for me to manually dig through the native code (few million lines) to identify it.
I was finally able to resolve the issue. I thought I will post the procedure here in case someone else is in a similar situation.
Step 1:
Build the native code with proper debugging symbols. The compiler flags could be something like "-g -rdynamic -O0".
Step 2:
The following valgrind command should do the job.
valgrind --error-limit=no --trace-children=yes --smc-check=all --leak-check=full --track-origins=yes -v $JAVA -XX:UseSSE=0 -Djava.compiler=NONE $JAVA_ARGS
In the above command, $JAVA is the java executable and $JAVA_ARGS is the arguments to your java program.
Once successfully started, it will take orders of magnitude more time to complete the execution. Valgrind will print thousands of errors (most related to jvm which can be ignored). You can however identify the ones that relate to your jni code.
This general strategy should be applicable to most native memory related problems.
If you are running Java under Linux, you could use the -XX:OnError="gdb - %p" option to run gdb when the error occurs. See this example.
Under windows, you can use the -XX:+UseOSErrorReporting option to obtain a similar effect.
For debugging JNI code a method posted in this article could be useful (it's about debugging JNI using Netbeans and Visual Studio). It's simple - just start your Java program, then in Visual Studio pick Debug -> Attach to process and choose java.exe process running your program.
When you add breakpoints to your C++ code, Visual Studio will break on them. Voila :)

I just installed Java Developer and now I do not know how to run it

I just installed Java Developer on Windows Vista. The installation process looked OK and it was successfuly finished. However, I do not know how I cun run this program? Nothing new on the desctop appeared?
First of all it is important to note that the Java Development Kit (JDK) is not a GUI tools such as Visual Studio. It consists mainly of pure command-line tools used to compile, run and debug Java code.
There are IDEs (Integrated Development Environment) which provide the entire Editor/Compiler/Build-System integrated in one big setup, but in my opinion the very first steps should be done with the pure JDK.
Start with this intial Java tutorial.
Generally The Really Big Index should keep you occupied for quite some time.
Fetch yourself a development environment like Eclipse: http://www.eclipse.org/ and start playing around.
The JDK is just that: a software development kit, sitting around in a directory specified by you and waiting for you to invoke its command line tools ...
If by "Java Developer" you mean the Java Development Kit (JDK), then you "run" it via the command line - use javac to compile and java or javaw to run the compiled classes.
If you mean you installed the JDK—the Java development kit—then this is just the Java compiler and the sources of the class library (roughly). You can then go ahead, create Java programs in any text editor and compile them.
But you probably want an IDE, such as Eclipse.
Go to Command Prompt. In the command prompt go to the directory where the Java program is located. In the command line type "java name_of_the_program.java". It will generate name_of_the_program.class. After that you can type (in the command line) "javac name_of_the_program" and the program will be executed.
It is how it should be in theory. But in practice it will not work. To make it work you have to find your java-directory (a directory where "javac.exe" is located). In my case it was "C:\Program Files\Java\jdk1.6.0_18". Then you have to create 4 new environment variables (classpath, include, lib, path) and set them to be equal to the name of the above mentioned directory. After that you need to restart your computer and after that will be able to compile your progam (by typing "javac name_of_the_program.java").
But of couse it is not the end of the story. If you type "java name_of_the_program" the program will not be executed. Java will write you that it is cannot find the main class. How to solve this problem I do not know yet.

Categories

Resources