How to run JPF in netbeans.? - java

I have completed all steps stated below
Download and install jpf-core, e.g. from the Mercurial repository
-------------- take a break ---------------
Download the gov-nasa-jpf-netbeans-runjpf.nbm file from here.
From within Netbeans go to Tools->Plugins (Alt+T followed by Alt+g)
Select the Downloaded tab
Click on Add Plugins... (Alt+A)
Select the gov-nasa-jpf-netbeans-runjpf.nbm file that was downloaded in step 3
Select install
Agree to the License agreement
Restart Netbeans
Now what i have to do to run the project?

Refer this official Documentation for the next steps.
https://github.com/javapathfinder/jpf-core/wiki/Run-JPF-with-NetBeans-plugin

1. Install netbeans-jpf (see: Installing the NetBeans JPF plugin)
2. Make sure the correct site.properties file is being used for JPF (The default is usually correct)
3. To see which site.properties file is being used:
4. From the NetBeans top menu go to "Tools"->"Options" (Alt+T followed by Alt+O)
5. Select "Miscellaneous" from the top of the Options Window
6. Select the "Java Pathfinder" tab
7. Make sure that "Path to site.properties" is defined properly, uncheck "Use default site.properties location" to change the path
8. From either the "Projects" or "Files" view (on the left of the main NetBeans screen by default,) select the JPF properties file (i.e., a file with a .jpf extension) you would like to run. Right click on this file and select the "Verify..." menu item to run JPF.
9. To view the results, make sure that the "Output" View is open (On the bottom of the main NetBeans screen by default)

Related

Proper way to configure IntelliJ to use source code for decompiled jar

I have been trying to figure this one out for a bit, not coming up with the right approach. I read through this question, which I'd already tried, but it's not working quite right.. using IntelliJ EAP 142.4675.3
What I am trying to do, is to debug a junit test using a jar (extending the Provider class) file I've placed into JAVA_HOME\jre\lib\ext. I want that jar to be debuggable as well.
The problem is, if I attach my source directory as the source for a jar, then, in a stack trace, when I click the named file (containing a method I wish to view), IntelliJ asks me to choose between two of the same file, presumably because it knows about the source (it's in a module in my project) and it's also been told about the source via the jar source path I added.
I tried adding the provider.jar to the project module dependencies tab, which caused intellij no end of grief. Reverted back to having it in jre\lib\ext, and, in the Platform Settings->SDKs->1.8->Sourcepath tab, I added the module sourcepath. This lets intellij step into the .java file for the jar, vs the .class file, but, when it does so, I now get a banner at the top of my code windows which says "Alternative source available for the class xxx" and there's a combobox at the RHS with the module name listed twice (in the latest EAP, it actually lists the module and the jar [same name as module, with .jar]). And, as mentioned earlier, the IDE asks which which (of the very same) file I wish to edit when I click a file in the stack trace.
Clearly, there is something not quite right.. what am I missing? I find it odd that the ide will not open the source code when stepping into the jar until I attach the code as above, but, when I do, it sees it twice.
So let's start from scratch:
File > New Project, choose "Java Module", fill the form:
Bypass the form asking about the kind of project (webapp etc) by clicking on "finish"
you now have a project with a src dir:
right click the 32910506 directory and choose "New" then "Directory" and create a new directory named lib.
drag and drop your 2 jars (sources and code) to this directory (I will use common-lang for this example), beware to copy, not move:
now right click on src, choose "New", "Java class", name it App:
right click your "code jar" and choose "Add as library":
in App type psvm then hit TAB to get a main and fill it like this:
right click on your "code jar" and choose "Open library settings":
click "+" and choose "Attach file or directory" and select your "sources jar":
Now if your Ctrl+click on random in App, you should end up to the method source:
Put a break point in the random method:
Now right click App, choose "Debug App.main()", you should end up to the previous breakpoint:
Used: idea 12.1.6 under linux

Debug Java Applet jar file in eclipse

I have a compiled jar file which is a compiled applet. I have the parameters and name of the class with the init method to start the applet.
I have installed jd-eclipse and would like to debug the applet in eclipse?
It should be pretty straightforward to do. Assuming at least Eclipse Galileo:
Create a project in Eclipse and add your applet jar(s) to its build
path. Alternatively you may choose to add the applet jar(s) to the
build path of an existing project.
Right-click your project, select Run As->Run Configurations Select
Java Applet in the left hand pane and click the New button at the top
of the pane
At the top, fill out a name for the new Run configuration, then on the
Main tab click to Search for your applet class.
On the Parameters tab, fill out all parameters from your existing
Applet HTML page.
Optionally, fill out any additional information you want the Applet
to have when it runs, on the other configuration tabs
When done, click Apply, then optionally Run to fire off the test
right away.
Good luck!

Viewing Java documentation with Eclipse on Mac OS X

I'm trying to accomplish a very basic task and somehow can't seem to find how... I would like to have my Eclipse environment set in a way that I can get help and documentation on any standard class/method in the JDK, like I used to do a few years ago with Eclipse on Windows, where having the cursor on a class name (e.g. PrintWriter), and clicking Ctrl+F2 would open up the Java documentation for the PrintWriter class.
Here's my environment:
Running OS X version 10.6.6.
Just downloaded and installed the Java Developer Package for Mac OS X 10.6 Update 4 from connect.apple.com
I have Eclipse Galileo installed.
Under /Library/Java/JavaVirtualMachines I have a file named 1.6.0_24-b07-334.jdk, which seems to be the new JDK I just installed. However, it's a single file, not expanded into directories and files. Right-clicking it and selecting "Show Package Content" shows me that deep inside it contains the files docs.jar and src.jar. However, not sure what I should be doing with the 1.6.0_24-b07-334.jdk file - should I leave it as is, or perhaps expand it to a full directory structure?
Under Eclipse Preferences, Java/Installed JREs I have JVM 1.6.0 (MacOS X Default) selected. However, the path points to /System/Library... and not to /Library...
Anyway, in Eclipse, putting the mouse over a class name, I get a brown dialog with a short explanation of the class. However, I don't know how to open up the full java documentation of the class. Also couldn't find anywhere in Eclipse a place to indicate where to take the java documentation from, nor which hotkey would bring the java documentation up.
I apologize for the many details, I'm just assuming they may be necessary to get a good answer.
Thanks!
/A
I've had the same problem — previously I had been able access Java documentation and source directly in Eclipse, but that disappeared after one of the Java updates from Apple last year.
My solution was to manually add the source and Javadoc to the JRE definition in Eclipse. Here's how:
Navigate to Preferences --> Java --> Installed JREs
Select your preferred JRE and click Edit...
Select the classes.jar library (should be the first one in the list) and click Javadoc Location...
Click Javadoc in archive
Set Archive path to /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/docs.jar
Set Path within archive to docs/api
Click OK
now, optionally, you can set the source code too...
With classes.jar still selected, click Source Attachment...
Set Location path to /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar
Click OK
In fact that 1.6.0_24-b07-334.jdk package is actually just a folder; it is treated as a single file by OS X but you can access its contents directly if you know the right path. What if you don't know what path the enter? You can browse the contents from Eclipse if you know this trick:
While attaching source code or Javadoc in Eclipse, click on the External File... or External Folder... button etc to bring up a Finder window
Navigate to your Java JDK folder (usually /Library/Java/JavaVirtualMachines)
You should see a list of your JDKs, for example 1.6.0_22-b04-307.jdk and 1.6.0_24-b07-334.jdk)
Press / on your keyboard to bring up the Go to the folder dialog box
Delete the / from the dialog box, and start typing the name of JDK you want to navigate. You can press Tab to autocomplete the name if you like.
Click Go
You are now browsing the contents of the JDK package; you can now click through to Contents/Home etc where you should see appledocs.jar, docs.jar, src.jar and other goodies.
For everyone finding this StackOverflow-Post and not finding the src.jar:
Apple removed it from the SDK and it's not supplied by default, however you can download it from Apple self at:
http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.9.3.3.1
http://danbim.blogspot.com/2011/01/java-for-mac-os-x-106-update-3-and.html
P.S. Apple account is required (free registration)
To bring up the Java documentation in Mac, move your mouse to the desired class, then click SHIFT+FN+F2.
By the way, you can find out the shortcut key from Preferences -> General -> Keys -> type "Open Attached Javadoc". Here's my screenshot:-
Under /Library/Java/JavaVirtualMachines I have a file named 1.6.0_24-b07-334.jdk, which seems to be the new JDK I just installed. However, it's a single file, not expanded into directories and files. Right-clicking it and selecting "Show Package Content" shows me that deep inside it contains the files docs.jar and src.jar. However, not sure what I should be doing with the 1.6.0_24-b07-334.jdk file - should I leave it as is, or perhaps expand it to a full directory structure?
From what I remember from Mac OS (I had to use one two years ago for some months) I think this is not really a "single file", it only looks so in the file manager application. Look if you can navigate inside it in the file-chooser dialog of eclipse where you can select the docs.jar for your documentation.
I was having a similar problem, and was having trouble accessing the Apple Developer page to download a local copy of the docs.jar. I went to Preferences > Java > Installed JREs > Edit, and then looked at the "Javadoc Location..." value for the jars. The Javadoc URI was still set to "http://java.sun.com/javase/6/docs/api/". When I changed it to "http://docs.oracle.com/javase/6/docs/api/" the tooltips started showing up again. Of course, this will only work when you are online.

How do I add the Java API documentation to Eclipse?

I have downloaded Java API documentation from http://www.oracle.com/technetwork/java/javase/downloads/index.html#docs and have supposedly attached it to Eclipse using the
Window->Preferences->Java->Installed
JREs->Edit->"Select rt.jar"->Javadoc
Location
And the location has been accepted and "Validates" just fine. However, for the life of me, I can't get Eclipse to show the Javadocs in the tooltip whene I hover over an item (for example in the declaration of an ArrayList). I have also restarted Eclipse in attempts to get it to work
What am I doing wrong?
To use offline Java API Documentation in Eclipse, you need to download it first. The link for Java docs are (last updated on 2013-10-21):
Java 6
Page: http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u25-doc-download-355137.html
Direct: http://download.oracle.com/otn-pub/java/jdk/6u30-b12/jdk-6u30-apidocs.zip
Java 7
Page: http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html
Java 8
Page: http://www.oracle.com/technetwork/java/javase/documentation/jdk8-doc-downloads-2133158.html
Java 9
Page:http://www.oracle.com/technetwork/java/javase/documentation/jdk9-doc-downloads-3850606.html
Extract the zip file in your local directory.
From eclipse Window --> Preferences --> Java --> "Installed JREs" select available JRE (jre6: C:\Program Files (x86)\Java\jre6 for instance) and click Edit.
Select all the "JRE System libraries" using Control+A.
Click "Javadoc Location"
Change "Javadoc location path:" from "http://download.oracle.com/javase/6/docs/api/" to "file:/E:/Java/docs/api/".
It must work as it works for me. I don't need Internet connection to view Java API Documentation in Eclipse anymore.
For offline Javadoc from zip file rather than extracting it.
Why this approach?
This is already answered which uses extracted zip data but it consumes more memory than simple zip file.
Comparison of zip file and extracted data.
jdk-6u25-fcs-bin-b04-apidocs.zip ---> ~57 MB
after extracting this zip file ---> ~264 MB !
So this approach saves my approx. 200 MB.
How to use apidocs.zip?
1.Open Windows -> Preferences
2.Select jre from Installed JREs then Click Edit...
3.Select all .jar files from JRE system libraries then Click Javadoc Location...
4.Browse for apidocs.zip file for Archive path and set Path within archive as shown above. That's it.
5.Put cursor on any class name or method name and hit Shift + F2
Eclipse doesn't pull the tooltips from the javadoc location. It only uses the javadoc location to prepend to the link if you say open in browser, you need to download and attach the source for the JDK in order to get the tooltips. For all the JARs under the JRE you should have the following for the javadoc location: http://java.sun.com/javase/6/docs/api/. For resources.jar, rt.jar, jsse.jar, jce.jar and charsets.jar you should attach the source available here.
Old question, but I had current problems with this issue. So I provide you my solution.
Now the sources and javadocs are inside the jdk. So, unzip your jdk version.You can see that contanins a "src.zip" file. Here are your needed sources and doc files.
Follow the path:
Window->Preferences->Java->Installed JREs-> select your jre/jrd and press "Edit"
Select all .jar files, and press Source Attachement.
Select the "External File..." button, and point it to src.zip file.
Maibe a restart to Eclipse is needed. (normally not)
Now you should see the docs, and also the sources for the classes from jdk.
I went through the same problem and I did not find some of the above answer useful because they are old and with new JDK 1.8 , documentation section has
been moved to src.zip in JDK folder (C:\Program Files\Java\jdk1.8.0_101 ) .
Now I tried everything from above and it was showing me the same problem if I press ctrl and click on (for example String or System) in my program I get the Source not found.
Now you can do this, go to the folder where JDK (C:\Program Files\Java\jdk1.8.0_101) is installed and try to unzip src.zip. Here you might face an issue as sometime due to administrative rights on this folder it would not allow you to unzip this src.zip. For solving the issue , copy src.zip and paste in any other folder ( example Desktop) and then create a folder src and unzip in it.
Now copy this folder back to JDK 1.8 folder**(C:\Program Files\Java\jdk1.8.0_101).**
Now just go to eclipse and open any program and press ctrl and click on any external objects or anything (for example String or System) .You will get Source not found , Now Click Attach source -> External Location -> External Folder and add your src location (C:\Program Files\Java\jdk1.8.0_101\src).
Now you are good to go , I tried and it worked for me.
All the above folder location are from my system , so It might be different for you.
Go to your JDK installation. (C:\Program Files\Java\jdk1.8.0_66 for me).
Unzip the src.zip file (becomes C:\Program Files\Java\jdk1.8.0_66\src\ for me).
In the Eclipse editor window: CTRL + Click on a java.lang library class. (something like String).
Eclipse will complain Source not found and tell you that you don't have the source.
Click Attach source -> External Location -> External Folder.
Find your source folder (C:\Program Files\Java\jdk1.8.0_66\src\ for me).
Click OK -> OK.
Enjoy.
Likely a problem with the path that you specified in Javadoc Location. It is pretty finicky. Make sure that it points at the root of where the javadoc starts. It could be a few directories down in the zip you've downloaded.
I have had a similar issue and looks like that the culprit was the space in the path to the archive (e.g., C:\Program Files\java\jdk). After moving the archive to another directory without spaces in path it started to work.
Instead of attaching JavaDoc attach JDK src.zip
Choose one class you want to view its documentation and press Ctrl+click over it, the Javadoc page will inform you that there is no Javadoc file attached and bellow will see a button named "Attach File". Press that button and browse to the directory where JDK is installed, normally for Win is C:\Program files\Java\jdk_xxx and inside this folder there is a src.zip file - sleect it and press OK and all is done - you already have Javadoc attached.
For OpenJDK 8 on Linux see: https://askubuntu.com/questions/755853/how-to-install-jdk-sources
The way that worked for me is:
The default src.zip is a symbolic link pointing to a non-existing folder ...
sudo apt-get install openjdk-8-source this adds this folder
locate "src.zip"
Eclipse: Window --> Preferences --> Java --> "Installed JREs", edit and point to src.zip (or open any JRE class like for example HashMap and attach source)
You should now see the JavaDoc when opening JRE classes via Ctrl+Shift+t, previously this was not possible, Eclipse may have got a docs from the default URL on mouse over methods but this requires a stable internet connection.
Ensure "Preferences" -> "Java" -> "Editor" -> "Hovers" -> "Combined Hover" is checked.
I just had to dig through this issue myself and succeeded. Contrary to what others have offered as solutions, the path to my happy ending was directly correlated to JavaDoc. No "src.zip" files necessary. My trials and tribulations in the process involved finding the CORRECT JavaDoc to point at. Pointing a Java 1.7 project at Java 8 Javadoc does NOT work. (Even if "jre8" appears to be the only installed JRE available.) Thus, I beat my head against the brick wall unnecessarily.
Window > Preferences > Java > Installed JREs
If the JRE of your project is not listed (as happened to me when I migrated a jre7 project to a new jre8 workspace), you will need to add it here. Click "Add..." and point your Workspace at the desired jre folder. (Mine was C://Program Files/Java/jre7). Then "Edit..." the now-available JRE, select the rt.jar, and click "Javadoc Location..." and aim it at the correct javadoc location. For my use:
For jre7 -- http://docs.oracle.com/javase/7/docs/api/
For jre8 -- http://docs.oracle.com/javase/8/docs/api/
Voila, hover tooltip javadoc is re-enabled. I hope this helps anyone else trying to figure this problem out.
if you are using maven:
mvn eclipse:eclipse -DdownloadSources=true -DdownloadJavadocs=true

How to add directory to classpath in an application run profile in IntelliJ IDEA?

I'm trying to add a directory to the classpath of an application run profile
If I override by using -cp x:target/classes in the VM settings, I get the following error:
java.lang.NoClassDefFoundError: com/intellij/rt/execution/application/AppMain
Any idea on how to add a directory to the classpath for my project?
In Intellij 13, it looks it's slightly different again. Here are the instructions for Intellij 13:
click on the Project view or unhide it by clicking on the "1: Project" button on the left border of the window or by pressing Alt + 1
find your project or sub-module and click on it to highlight it, then press F4, or right click and choose "Open Module Settings" (on IntelliJ 14 it became F12)
click on the dependencies tab
Click the "+" button on the right and select "Jars or directories..."
Find your path and click OK
In the dialog with "Choose Categories of Selected File", choose Classes (even if it's properties), press OK and OK again
You can now run your application and it will have the selected path in the class path
It appears that IntelliJ 11 has changed the method, and the checked answer no longer works for me. In case anyone else arrives here via a search engine, here's how I solved it in IntelliJ 11:
Go to the Project Structure, click on Modules, and click on your
Module
Choose the "Dependencies" tab
Click the "+" button on the right-hand side and select "Jars or directories..."
Add the directory(ies) you want (note you can multi-select) and click OK
In the dialog that comes up, select "classes" and NOT "jar directory"
Make sure you're using that Module in your run target
Note that step 5 seems to be the key difference. If you select "jar directory" it will look exactly the same in the IDE but won't include the path at runtime. There appears to be no way to determine whether you've previously selected "classes" or "jar directory" after the fact.
You can try -Xbootclasspath/a:path option of java application launcher. By description it specifies "a colon-separated path of directires, JAR archives, and ZIP archives to append to the default bootstrap class path."
Set "VM options" like: "-cp $Classpath$;your_classpath"
I am using Idea 8.
in your module dependancies tab (in the project structure dialog). Add a "Module Library". There you can select a Jar Directory to add. Then make sure the run profile is using the Classpath and JDK of the correct module when it runs (this is in the run config dialog.
Simply check that the directory/package of the class is marked as "Sources Root". I believe the package should be application or execution in your case.
To do so, right click on the package, and select Mark Directory As->Sources Root.
You need not specify the classes folder. Intellij should be able to load it.
You will get this error if "Project Compiler output" is blank.
Just make sure that below value is set:
Project Settings -> Project -> Project Compiler output
to your projectDir/out folder
Open Settings
Under project Settings, select "project settings (1)"
On the left, select "modules"
Select the desired module
Select the "Sources" tab
In the tree structure, find the directory you want to add. Then either add as a source or test source.

Categories