Do not know how to get this pdfbox annotation example to run - java

Hi I found this example of pdfbox using annotation:
https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/AddAnnotations.java
When I try to run it in netbeans, nothing happens except to print in output:
Usage: add_annotation_exp1.Add_annotation_exp1$AddAnnotations
Not sure what I am doing wrong

There are two possible solutions (based on Netbeans 8.2):
1)
In the main method, add this at the beginning: args = new String[]{"c:/path/filename.pdf"}; and then build the subproject and then press SHIFT F6 to run, or right-click in the editor pane and choose "Run File". (If the subproject is open then you can skip the build step)
2)
Go to the subproject properties (right-click on the left pane on "Apache PDFBox examples"), "Properties". A dialog box will appear. Choose "run" in the left pane. In the field "Main Class" enter org.apache.pdfbox.examples.pdmodel.AddAnnotations (or use the "Browse..." button), and in the field "Arguments" enter your file name with the path. Use quotes if there are spaces in the path. Then run by clicking the right mouse key on the subproject and choose "Run".

Related

Intellij highlight file in Project Explorer

In Eclipse, one can choose a File in Editor, right click and hight-light the file in Project Explorer. That will expand the tree, and one can see the file highlighted.
I'm wondering how one can accomplish the same in Intellij IDEA.
There is a shortcut: ALT + F1 then select 1.Project View.
Or you can press Scroll from Source button:
If you're a fan of keyboard shortcuts like me, you can also assign one via Settings - Keymap
Adding to Ruslan answer, you can also decide to automate the process and keep the Project ToolWindow always in sync with the currently opened editor.
Just tick the Autoscroll * menu items.

Cannot be resolving in JAVA

I'm new in java and found this after importing project
How can i solve it?
Go to Window > Show View > Other.... Choose General > Problems or search for Problems and add it. Look for the exact reason for red marks on your packages.
Update
Looks like your source folder is misplaced. Follow the steps below:
Right click on the project, go to Properties
Choose Java Build Path on the left pane.
Click on <Project_name>/src and click Remove
Click on Add Folder, choose check boxes (if found) java & resources under the trees src>main and src>test
Click OK and then OK on Properties dialog.
Image reference:

how to open specific Jframe as a main jframe?

when I run the project compiler says BUILD SUCCESSFUL but not any window is appear. when I runt the project I want to start main_window as a default window. but I have no Idea how to setting up this.
If you are creating a jar file (as I assume you will be doing from your previously deleted question), the main class would be specified by the jar file's manifest.
e.g., the manifest file, named MANIFEST.MF could contain a line looking like:
Main-Class: gui.main_window
Right Click on the Netbeans tool-bar. An drop down menu should appear. Select Customize and scroll down through the options until you see Run File. Drag the button onto the tool-bar. Now select the main_window.java and hit the Run File button.
The IDE should run only the file.

Java - setting classpath

My sample application tells me:
No 'qtjambi-deployment.xml' found in classpath, loading
libraries via 'java.library.path'
I wish for my application to use the qtjambi-deployment.xml, but unfortunately can't find the appropriate setting in IntelliJ IDEA 10.5.
Could someone help me?
You can right click on any directory in your IntelliJ project, select "Mark Directory As...", and choose "Source Root". That director folder will change color from yellow to blue; IntelliJ considers all those directories to be in your CLASSPATH.
From the top menu click 'Run' => 'Edit Configurations'
Choose the right 'Application' in the left column (if it's not yet selected)
Click on 'Configuration' tab in the right hand side column (if it's not yet selected)
Click the '...' button to the right of 'Environment variables:'
Click the '+' button.
qtjambi-deployment.xml file is situated in qtjambi-win<architecture>-msvc<year>-<vertion>.jar. Add this package to your classpath and your building problem will be solved. I hope)

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