Eclipse v3.7.1 on OS X: Wacky compiling errors - java

I'm trying to compile Nachos OS in eclipse. The project compiles fine when I run "make" (which calls javac), but when I try to run it in eclipse, it spits out some bizarre java errors. For example, it is reporting that the last line of this javadoc comment is a file that it is unable to find...
Code Fragment:
/**
* The master class of the simulated machine. Processes command line arguments,
* constructs all simulated hardware devices, and starts the grader.
*/
public final class Machine {
/**
* Nachos main entry point.
*
* #param args the command line arguments.
*/
public static void main(final String[] args) {
System.out.print("nachos 5.0j initializing...");
Error Output:
/Users/dan/git/nachos/machine/Machine.java: line 19: */: No such file or directory
/Users/dan/git/nachos/machine/Machine.java: line 20: syntax error near unexpected token `('
/Users/dan/git/nachos/machine/Machine.java: line 20: ` public static void main(final String[] args) {'
I am using OS X 10.7.2 (Lion) with Java SE 6 (1.6.0 jdk).
I have configured the build settings to use Nachos' Machine.Machine.java main function.
Any idea why the odd output from Eclipse?

Seems like the project file got corrupted in the process of loading it onto a bitbucket server. I dropped eclipse like a bad habit in favor of IntelliJ. Soooo much happier now.

Related

Netutils in java - Exception occurs [duplicate]

This question already has answers here:
What is LD_LIBRARY_PATH and how to use it?
(6 answers)
Closed 8 years ago.
I am using Netutil class in my simple java app to show all network interfaces, the program code is as follow and the exception result after that. I am absolute beginer and your help is big time saver for me :)
package packet_experience;
import edu.huji.cs.netutils.NetUtilsException;
import edu.huji.cs.netutils.capture.*;
import java.io.IOException;
/**
*
* #author Pete
*/
public class Packet_Experience {
/**
* #param args the command line arguments
* #throws edu.huji.cs.netutils.NetUtilsException
* #throws java.io.IOException
*/
public static void main(String[] args) throws NetUtilsException, IOException {
JPCapInterface intArr[] = JPCap.getAllIntefacesNames();
for (JPCapInterface next : intArr)
{
System.out.println(next.toString());
}
}
run:
Exception in thread "main" java.lang.UnsatisfiedLinkError: edu.huji.cs.netutils.capture.impl.JPCapWraper.get_all_devices(Z)Ljava/lang/String;
at edu.huji.cs.netutils.capture.impl.JPCapWraper.get_all_devices(Native Method)
at edu.huji.cs.netutils.capture.impl.JPCapWraper.getAllInterfaces(JPCapWraper.java:299)
at edu.huji.cs.netutils.capture.JPCap.getAllIntefacesNames(JPCap.java:346)
at packet_experience.Packet_Experience.main(Packet_Experience.java:29)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)
Update (Solution!):
My CPU is CORE i5 and having Win 7 Home Pre 64bit.
I tried JVM 32 and 64bit and changed System_PATH and java.library.path and copied all jar, dll, lib,... files there as well. Also I followed and performed recommendation I received on this page and I read in any other place ( as far as I could understand :) ).
At end I encountered with jnetpcap which has similar performance and I recommend it instead as works perfectly for me. You can find it at jnetpcap Homepage . Note that the same as Netutils you should adjust System_PATH and java.library.path and make sure you use JVM 32bit, otherwise you will definitely receive UnsatisfiedLinkError.
Have fun!
The error looks exactly like "You need a dll/so".
Try looking here:
NetUtils java library - how to make it work?
You will find the .dll somewhere on Your computer, just search Your windows dir.

Java compile errors ISeries QShell

I have the following helloworld class
class HelloWorld {
public static void main (String args[]) {
System.out.println("Hello World");
}
}
This is in an ASCII streamfile on the IFS called helloworld.java. When I try and compile this in QSH I get the following error
javac helloworld.java
helloworld.java:2: ')' expected
public static void main (String args[]) {
¢
I can't see a missing ')' in line 2. I suspect this is a codepage error because I've also never seen ¢ as placeholder on compile output.
Any ideas ?
Personally, I would suggest edit, compile, and test, your java code on a workstation (PC or Mac) and not trying to compile on the IBM i.
It's much more efficient that way.
Once you have code that works the way you want it to on your workstation, create a deployable JAR file and move that to the IBM i for further testing.

how to use java native (cacls) for change file permission in windows

i had tried these syntax , but why it didn't work?
i really glad for your advice.
thanks before. sorry for bad english.
package priviledge;
import java.io.File;
import java.io.IOException;
/**
*
* #author DINA
*/
public class Main {
/**
* #param args the command line arguments
*/
public static void main(String[] args) throws InterruptedException, IOException {
File f = new File("C:/lala/images1.jpg");
permission(f);
}
public static void permission(File src) throws InterruptedException, IOException {
// win32 command line variant
Process p = Runtime.getRuntime().exec("cacls 000 " + src.getPath());
p.waitFor(); // p.waitFor()
Because cacls works differently from chmod. In particular, the first argument is a file name (which would mean you try doing that on a file named 000). Windows using ACLs further comlpicates things as they don't fit as nicely into three octal numbers.
Look up the documentation of cacls (just type it at the command prompt) and fix your command line.
for cacls a group is the same as a user so for example to grant Full permission to the ABC group you would type "cacls filename /g ABC:F" You can view more details on the documentation of cacls
I was also working on a project which Involves changing Permissions of a folder. I tried many methods, but didn't work as I was expecting, So, I came up with a new Idea. For That you need basic knowledge about Batch files,
I wanted to change permission of a folder, So, This is what I did:
Created a text file, Wrote the commands in that file, Converted it into a batch file, and executed it using:
File file = new File("server.bat");
Desktop.getDesktop().open(file);
(Works for java 1.6 or newer), Deleted that batch file.
It may be a long way to do that, But in this method can execute any number of commands at a single shot. With this method, You don't have to worry about working directory as you can change it in the batch file. This may be a bad idea, I am new to java, But I told You my idea.

System.out.println doesn't work?

When I write this in the main method:
System.out.println("Hello");
Nothing is outputted on the output console. It just says "Build successful (total time: 0 seconds)". What's the problem?
Here is my full program:
package names;
public class myName {
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("test");
}
}
Here's the window after I debug the program:
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsfd.jar
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/laf.jar
Have no file for /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/sunrsasign.jar
BUILD SUCCESSFUL (total time: 1 second)
On netbeans right click and click run file. It would run. Seems like you're building the project, and not executing it.
Don't debug it. Run it.
I'm nearly sure it's due to an IDE issue: the ant/build output is being redirected to a different place (not stdout) and you're seeing that "other place" as a "Console". Please let us know your IDE and as much code as you can.
You have to run it then. In netbeans, to run you can press F6 - http://netbeans.org/kb/docs/java/quickstart.html

Running R from terminal via Java

I'm trying to run R using Java. I have R installed on my Mac and I've used it plenty of times from the terminal.
In the terminal, to start R, one simply types "R"
Ex:
Macintosh-11:Desktop myname$ R
R version 2.12.2 (2011-02-25)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>
So, what I would like to do is run R through Java, via the terminal. So, I wrote myself a Java class:
public class javar {
public static void main(String[] args) throws Exception {
Runtime.getRuntime().exec("R");
}
}
However, when I compile and then execute, using
java javar
I don't see R start. I simply see the program finish executing, and then the terminal is ready for another command.
How can I achieve what I'm trying to do?
when I encountered your problem, I ended up using JRI, which not only creates an R/Java connection, but allows you to exchange matrices and vectors to/from the two.
Although I don't suggest it, your approach may work, but R will not "hang" after you launch it, it will just execute nothing and exit. Try adding the "--vanilla" option and obviously feed some code to it, with --file=yourScript.R and eventually arguments using --args
public class javar {
public static void main(String[] args) throws Exception {
Runtime.getRuntime().exec("R --vanilla --file=yourScript.R");
}
}

Categories

Resources