I use SPEC as a tool to measure java files running time.
I'm using SPEC2008 which can be downloaded here.
I installed spec2008 (java -jar SPECjvm2008_1_01_setup.jar) and ran it (java -jar SPECjvm2008.jar as written in the README file).
I got a results file and a report that everything completed successfully.
Now i need to examine how some changes affect SPEC's running time.
I made the changes in some of SPEC'S files (the java files inside the following folders: compiler,compress,crypto,derby).
Now i can't run it again using java -jar SPECjvm2008.jar because the changes i made include jomp commands (\\omp parallel for and such). [JOMP is OpenMP for JAVA]
To compile files with such commands i used to do the following:
First, download JOMP. Then:
change .java extension to .jomp . Then type:
java jomp.compiler.Jomp MyFile
(now i got a .java file)
compile to .class:
javac -classpath YourJompDownloadPath\jomp1.0b.jar; MyFile.java
java -Djomp.threads=n MyPackage.MyFile
So i can't do this now because:
There are too many files and it would take time changing all extensions to .jomp
There are too many files and i need to run all of them as a whole (just as SPEC does), but in JOMP commands i only know how to run each file independently.
If there's a workaround for #2 then i'll do #1 manually. So i'm especially looking for a solution/workaround for #2.
edit:
OK so i made a .BAT file only for step 1 (see method here) because it seems that SPEC has only .java files so i'll provide it with .java files only. For the 2nd step i think i need to just run SPEC (java -jar SPECjvm2008.jar). For the 3rd step, i think instead of normally running SPEC, i need to run it with the parameters in step 3 (Djomp.threads). That is:
java -Djomp.threads=n -jar SPECjvm2008.jar
Now there's a new problem. I get the warning:
Recompile with -Xlint:unchecked for details
Which was addressed here. But in that link it's run with javac and not java. javac doesn't recognize the parameter Djomp.threads (and java doesn't recognize Xlint). So i think i'm looking for a way to run a .jar file while using Djomp.threads and Xlint.
Note: running the .jar file SPECjvm2008.jar eventually runs the java files i need. That's why i said "i'm looking for a way to run a .jar file..."
Related
Currently I'm building a small personal project in Java which is a simple file server. I've implemented basic internationalization with usage of ResourceBundle. I'm using .properties files to store messages in different languages.
Till now I was using Vscode built-in java compilation process which was copying .properties files into its corresponding directory in the output. However now I'd like to write a build script for that project.
My command looks like this:
javac -d ./bin -cp ./src ./src/**/*.java.
This command however doesn't take .properties files into account. I searched web whether javac has ability to somehow process/include this files into output but found no answer. I know I can use Maven or Ant, but I'd like to make this project without usage of additional tools.
Answering to my own question, but maybe someone will find this useful one day. In short javac always compiles .java files producing .class files. There is no way that it could process some other file (source:
How to set the output files when compiling with javac).
Long story short if you want to include resources, images, text files, anything that is not .java file in your output, and don't want to use build tools, you have to copy it manually or use cp command in your build script.
I've been wanting to reverse engineer this clients launcher in an effort to understand how the game was launching as a Java application despite it only having a PE32 executable alongside it.
The launching of the client goes as follows:
java -Xmx384M -Dfile.encoding="UTF-8" -cp TargetBinary.exe com.java.client.Client
Now I was curious what TargetBinary.exe actually was, as this was being ran on a *NIX system. Running file I observed this output.
TargetBinary.exe: PE32 executable (GUI) Intel 80386 (stripped to external PDB), for MS Windows
The second part is the com.java.client.Client after the TargetBinary.exe, this stands out as a Java pathing which Client is my target.
Here are my questions:
How can Java add the TargetBinary.exe to its classpath?
As a followup, are there any recommendations to decompile it to the point where I can observe Client and more so understand how it was all packed together?
Being a Portable Executable (PE) the libs, code, etc should all be there inside the TargetBinary.exe and somehow Java knows what to do with it?
Zip files are read from the back, so it's easy to put a zip (jar) file at the end of an executable file, and have it work as both.
See https://en.wikipedia.org/wiki/ZIP_(file_format)#Structure
Try running jar -tvf TargetBinary.exe to see the names of the classes and resources in the jar. If you make the file a dependency of a project in your IDE you can see decompiled code and navigate around the project, and run it and set breakpoints.
I'm a hobby coder using CodeAnywhere to allow me to, well, code anywhere without having to set up a development environment. It's admittedly not the fullest featured IDE, but it gets the job done. One limitation is that I can't use Ant or Maven, so I have to figure out how to build using plain old javac (via SSH).
So I've created a little bash script that creates a file with the relative paths to all the source files, and then pumps that into javac:
find -name *.java > classes.txt
javac #classes.txt
The first line works fine and generates the anticipated output. The second one also appears to work, and even gives me compile errors (which I was expecting). However, there are a few classes that should compile, but the corresponding class files are not generated. Is this anticipated behavior? Why does it work when I manually include multiple file names as arguments (even when I include ones that generate errors), but not when I use the #file notation?
I am new to java, Now i am learning. So i googled sample java websites. for example i downloaded source code for online reservation system.
In that code,it have install.bat and start.bat file. May i know what is the use of this file?
Can anyone explain me? Thanks in advance.
You can find out what theese files do by taking a look inside. .bat files are written in plain text. Each line contain one or several commands that can be interpreted and executed by cmd.exe. This kind of files aren't only used for java but for lots of purposes. In your case they are used to launch a java program. In contrast to e.g. C++ Java won't give you an .exe file that you can start by doubleclicking on it. It compiles your code into a .jar file. In order to launch this file you must call the Java virtual machine and tell it to start your jar file (there are some more parameters which you don't have to care about while you are just starting with Java).
However, it will take a while till you'll have to deal with BATCH files. By now you should use your IDE (I would recomend Eclipse) which allows you to start your progrgam without taking care of how to do it. You just hit the "Play"-Button and get your result.
They're nothing to do with Java per se.
They're Windows batch scripts, and from the names, it looks as though one of them is there to install the application on your machine, and one is there to start the application up.
Java is cross-platform, which is a strength for the most part, but it does mean that sometimes applications need a little bit of boilerplate code for starting the application on different platforms. So sometimes you will see Java applications that have a Windows batch file or similar for starting on Windows, and a shell script for starting on Linux, and so on.
Batch files with the extension .bat have nothing to do with Java. They are Windows-specific shell scripts, introduced with MS-DOS in 1981.
A set of multiple commands called as a batch file. Say you are been assigned to compile a set of classes, create jar file and execute. This can be done with a simple batch file like this:
activity1.bat
REM set java home path
set JAVA_HOME=C:\Program Files\java\jdk1.7.0
REM set path
set PATH=C:\Program Files\java\jdk1.7.0\bin
REM set class path
SET CLASSPATH=..
REM compile class files
javac -cp %CLASSPATH% %CUR_DIR%*.java
REM create a jar file
jar cfm new.jar Manifest.txt *.*
REM execute
java -cp %CLASSPATH%;new.jar MainClass.java
PAUSE
Note: REM meant for comments.
COMPLETE EDIT BUT SIMILAR PROBLEM
What's the best software/plugin to enable FTP on Eclipse? I'm using FileZilla, but is there something better/easier?
You are telling javac to compile gamedata.txt and it is reporting an error that it cannot compile this file.
I'd highly suggest using a tool like Ant to script your compilation/packaging/etc so you don't have to worry about typing in arguments on the command line.
First of all, the -J command line argument is not meant to be literally passed as -J<flag>. Taken directly from the javac man page (you can view the exact same thing by typing man javac into the shell):
-Joption
Pass option to the java launcher called by javac. For example,
-J-Xms48m sets the startup memory to 48 megabytes. Although it
does not begin with -X, it is not a `standard option' of javac.
It is a common convention for -J to pass options to the underly-
ing VM executing applications written in Java.
Really, if you want to make this an executable, you can just use the tools that exist in Eclipse to make an executable. Using the command-line javac adds an extra level of complexity that is unnecessary, and that Eclipse is specifically designed to remove.
In eclipse, you can (I think) use File->Export->Java->Executable JAR File to make your project into an executable JAR that any computer with the Java Virtual Machine can run. That way, your project will work on both your computer and the Unix system at your school. You may have to add gameData.txt manually to the JAR or include it separately in the package, not sure how Eclipse does that type of thing though.
You can only compile .java files. If you remove the .txt file from the list of files to compile, it should work fine. If you want to compile all the files in a directory, you can simply use javac *.java
There are some examples in the javac synopsis.
Edit: Updated link to Solaris examples, which are similar to Linux.