Manually Include Java API?

May 7, 2014

For some reason, when I generate a Javadoc (using javadoc.exe of JDK 8), it displays Java-defined classes like java.lang.String and java.lang.Object by their full names rather than simply String or Object. Only the classes inside the packaged contents were represented by their simple names and linked to them (had visible coloured bolding). Was I supposed to manually include the Java API?

View Replies


ADVERTISEMENT

How To Include Java File In All Projects

Mar 23, 2015

1) I have a file .java with some great functions, this functions i need use in all projects, then what is the easy by moment i start a project, and copy this file to project.. is possible have only 1 file with these utilities functions? (if yes how to declare or use in all projects?)

Note these utilities file i want use on JAVA desktop(swinf and javafx), on JSP webpages and in the futhurer on the mobile.
 
2) I have a JSP project in 1 .JSP file i have 8 Tabs (CSS tabs) when user click on tab1 i execute some jsp java code. and if user click on tab2 i execute a different JSP code, but my problem is, the JSP file is large large large, 1500 lines, my question is: is possible (similar in PHP) do an include?
 
<%
   include tab1.jsp
%>

View Replies View Related

How To Manually Put Data Into InputStream

Aug 23, 2014

I am new to programming in regards to I/O, channels, SSH, etc...

At the moment I am trying to transform the Shell.java program from the JCraft JSch examples; JSch - Java Secure Channel - Examples

The way in which I am trying to transform it is by instead of having the character input go into the channel automatically from the keyboard (refer to line 77 in Shell.java), I just want to pro-grammatically insert characters in to the channel at my discretion, so for example I have a string called unixCommand that I want to insert into the channel, and I don't want there to be any other way of inserting into the channel such as the standard input stream, so for example I'd have the statement <insert unixCommand to UNIX box at other side of channel> inserted somewhere after line 100 in Shell.java.

I was thinking that maybe I have to use some other InputStream object at line 77 when setting the channels input stream instead of System.in, but I am not sure how to do this (but really I'm not sure if I'm even on the right tracks?). I believe all this confusion may be down to a misunderstanding with the general concepts involved with channels and I/O ...

View Replies View Related

How To Manually Put Data Into InputStream

Aug 23, 2014

I am trying to transform the Shell.java program from the JCraft JSch examples : [URL] ....

The way in which I am trying to transform it is by instead of having the character input go into the channel automatically from the keyboard (refer to line 77 in Shell.java), I just want to pro-grammatically insert characters in to the channel at my discretion, so for example I have a string called unixCommand that I want to insert into the channel, and I don't want there to be any other way of inserting into the channel such as the standard input stream, so for example I'd have the statement <insert unixCommand to UNIX box at other side of channel> inserted somewhere after line 100 in Shell.java.

I was thinking that maybe I have to use some other InputStream object at line 77 when setting the channels input stream instead of System.in, but I am not sure how to do this (but really I'm not sure if I'm even on the right tracks?). I believe all this confusion may be down to a misunderstanding with the general concepts involved with channels and I/O.

View Replies View Related

Repeating A Program Until Manually Terminated?

Jun 22, 2014

My homework assignment is to create a program that reads two military times and then prints out the elapsed time. I've got all that down and ready to go but then the other part of this project is to have it loop until it is terminated manually. So at the end where it asks for a 'Y' or 'N' input answer is where I know i need to implement a do-while loop or switch statement, I'm not sure. how to make the application repeat until told to quit.

View Replies View Related

Manually Add Exception Table Entry?

Apr 8, 2014

because of the need to implement a certain software watermarking technique I have to manipulate the exception table.
 
(Link to the paper that describes the technique: [URL] .... (Section "Extension to Java Bytecode")
   
So far I could manually add the exception table entry with Javassist:
 
MethodInfo minfo = (MethodInfo) aclasscf.getMethods().get(0);
CodeAttribute ca = minfo.getCodeAttribute();
ExceptionTable et = ca.getExceptionTable();

[Code]....

View Replies View Related

JSP :: Include From A Different Folder

Apr 17, 2015

I am creating a very simple webpage where I am using just a little bit of JSP to include partials (header, footer and asides) that are centrally located. One of the constraint that the site owner has put is that, for SEO reason, he wants to keep the url's the way they are. Most of the pages are located in the same folder, except for one which is in a subfolder.

Here is my problem, I have the partials in a folder and at the same level the images. Now, for that page located in the subfolder, when I include the partials, it is not able to locate the images because they are located in a folder one level up. What I could do is create a copy of the image folder in the subfolder or an adapted copy of the partials (referring to the images one level up), but either solution would make for a maintenance nightmare and repeat information on the server.

Here is a visual representation of my file system:

- Top level folder
- Partial_Folder
- header.html
- footer.html
- images
- picture_1.jpg
- Page_1.html
- Page_2.html
- Another_Folder
- Page_3.html

View Replies View Related

Swing/AWT/SWT :: Manually Select A Node In JTree?

Oct 24, 2014

I have problem with manually (through my java code) selecting items in a JTree. I did Google the problem and found solutions here :

[URL]

This code worked for me only partially. Once I tried selecting deeper nested nodes, I ran into problems. Since my production code is very cluttered I built an example and reproduced my exact problem in it.

DummyView.java
package de.fortis.tcws.client.controller;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

[code].....

The important method is 'manualSelect(String[])'.

It streps through the tree by comparing user objects and finds the target node. Then it calls 'navigateToNode()' which uses the solution discussed in the links above.

This method behaves incosistently:

If you call it with an empty array it will correctly select the root node. The righthand pane shows the text of the selected node. = correct

If you call it with target node 1 it will correctly select node 1. The righthand pane shows the text of the selected node. = correct

If you call it with target node 1.1 it will select node 1.1 but for some reason it is not displayed as marked (no background). The righthand pane shows the text of the selected node. = only partly correct

If you call it with target node A it will run into an exception. Debugging reveals that the selection occurs correclty at first. You can also observe the righthand pane showing that 'A' was selected. But afterwards another TreeselectionEvent is occuring that has a NewLeadSelectionPath of null. I do not know where this second SelectionEvent is triggered from.

This code is run with Java 1.6.0_39 which is also what I will have to use in production.

View Replies View Related

Manually Adding Exception Table Entry

Apr 7, 2014

I use Javassist to manually add a exception table entry:

Java Code:

MethodInfo minfo = (MethodInfo) aclasscf.getMethods().get(0);
CodeAttribute ca = minfo.getCodeAttribute();
ExceptionTable et = ca.getExceptionTable();
et.add(26, 30, 40, 0);
System.out.println("exception table size: " + et.size()); mh_sh_highlight_all('java');

If I get the bytecode with javap it seems to work:

Java Code:

Exception Table
from to target type
26 30 40 any mh_sh_highlight_all('java');

But the problem is that I can't run the file anymore. Simply running it with the java command results in "java.lang.VerifyError: Expecting a stackmap frame at branch target 40". After some research this seems to be a problem with java 7 and a stricter verifier. I read several times that java -XX:-UseSplitVerifier should be used instead.

This really fixed the stackmap error, but then another error appeared: "java.lang.VerifyError: (class: AClass, method: signature: ()V) Inconsistent stack height 2 != 1". Are there any further steps required to insert a new exception in the exception table?

Additional info: Later I want to remove gotos (in this case the goto at line 27) and add a function call instead. When this function finishes it will throw a exception and propagate it back to the caller (which will be at line 27). Then the program should go on as if nothing happend, that is also the reason why the target of the exception is the same as the target of the goto (40)

Here is the bytecode:

Java Code:

0: aload_0
1: invokespecial #8 // Method java/lang/Object."<init>":()V
4: iconst_0
5: istore_1
6: goto 19
9: getstatic #10 // Field java/lang/System.out:Ljava/io/PrintStream;
12: iload_1
13: invokevirtual #16 // Method java/io/PrintStream.println:(I)V

[Code] .....

Exception table:
from to target type
26 30 40 any mh_sh_highlight_all('java');

View Replies View Related

How To Call Action Listener Automatically And Without Doing It Manually

May 16, 2014

I'm not a java developer, i'm a tester. I am currently testing a java swing application and to do that I have to automate how its used. IE I have to write code which will press buttons for me rather than depending on an end user to do this. I have managed to reverse engineer the entire application (hooray for me), however I am struggling to work out how to invoke methods that would typically be kicked off by a user pressing a button. how to I can call actionPerformed(ActionEvent ae) method which sits in the ATMMainPanel class?

I will be calling it from inside another method which is the equivalent of the main() method.

Java Code:

public class ATMMainPanel extends JPanel implements ActionListener {
[declarations here]
//here - User is pressing the Enter button after putting in pin.
public void actionPerformed(ActionEvent ae) {
[code performed when button is pressed]
} mh_sh_highlight_all('java');

View Replies View Related

Include EAR File In Classpath?

Jan 23, 2014

I am writing an Ant script using the javac command but the library I need is bundled in an ear file, how can I reference this jar in ear file without extracting the ear file.

View Replies View Related

How To Include Multiple UUIDs In Single Variable

Dec 31, 2014

My application depends on eight default user roles (or account types). They can be renamed or disabled, but should not be deleted. I want to protect them from deletion using their uuid value from the db. How can I pass their uuids into a single variable so I can use that single variable in my conditional statement? If I should use an array, any example of how I might do this?

View Replies View Related

Rectangle Class Include Try-catch And Exception Handling

Oct 18, 2014

The requirement is to write a rectangle class and a test class, which include try-catch blocks and exception handling. Exceptions, involving try, catch, throw, throws, and finally commands,how to write a code about basic things, but in the test class, it gives me specific width and height so that i dont konw how to write a try-catch blocks an exception handling in this test class.There is my two classes, they are separated.

public class Rectangle {
double width ;
double height ;
Rectangle(){
width = 1;
height = 1;

[code]....

View Replies View Related

Calculator Program - Use Strings And Methods To Include Arrays

Jul 23, 2014

My assignment is to essentially update a calculator program that uses strings, and methods, to include arrays. How to create and call an array that the user defines the size of and then inputs the numbers to fill the array. Here's the example my prof gave us of what the output should look like:

Menu
1. Add
2. Subtract
3. Multiply
4. Divide
5. Dot product
6. Generate random array
7. Quit

What would you like to do? 1

How many values are in the arrays? 3

Enter the values in the first array, separated by spaces:
2 4 6

Enter the values in the second array, separated by spaces:
1 3 5

The result is [3.0, 7.0, 11.0]

How to create an array that would allow the user to define the size of the array and then inputs the values for the array? I'm completely lost. I never should have taken java as an online class.

View Replies View Related

Create A Database Configuration File And Include All Other Files

Apr 19, 2014

I am creating an application in core java where i am using database. I need to create a database configuration file & include it all other files. So, how can i do that ?

Java Code:

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:MYDSN","system","tiger"); mh_sh_highlight_all('java');

I cannot do this in an interface since only abstract methods exist there. I tried to create an another class file to extend it but my program is already extending other class i.e. javax.swing.JFrame..How can i implement this ? just by creating the object of that class in main method ?

View Replies View Related

Applets :: Embedding Images - How To Include Actual JPGs

May 7, 2014

I have an applet that uses JPanels to draw images in. I want to include actual jpgs now instead. The applet points to a .jar file. I want to use any number of images here, do I have to include them all in the jar file or is there another way to "point" to them (like html)?

View Replies View Related

Include Three Sides Of Triangle Formatted To Two Decimal Places

Sep 9, 2014

My program is supposed to include The three sides of the triangle formatted to two decimal places The perimeter formatted to one decimal place The area formatted to one decimal place The unformatted area. It does run, but it is not decimal formatted. I have read my book to try and figure out how to do this, but it doesn't make since to me.

import javax.swing.JOptionPane;
import java.util.*;
import java.text.DecimalFormat;
import java.util.StringTokenizer;
 
public class ShelbyHarms_3_03 {
public static void main (String [] args) {
double a, b, c; //Input sides of triangle

[Code] ....

View Replies View Related

Random Phone Number Generator - Include Dashes In The Output

Apr 11, 2011

I've been working on a personal project again in Unit 3 of my text book and this time they want me to make a random phone number generator. Here's the actual directions:

"Write an application that creates and prints a random phone number of the form XXX-XXX-XXXX.

Include the dashes in the output.

Do not let the first three digits contain an 8 or 9 (but don't be more restrictive than that), and make sure that the second set of three digits is not greater than 742.

Think through the easiest way to construct the phone number. Each digit does not have to be determined separately."

With this assignment I came across 2 problems:

1. What I tried was that since the first 3 numbers have to be a random number with no 8's or 9's I tried doing this algorithm:

int first0, first1, first2, second, third, random0;
first0 = generator.nextInt (999);
random0 = generator.nextInt (8);
first1 = first0.replace('8', random0);
first2 = first1.replace('9' random0);

The problem is that Java won't allow me to generate random numbers this way. Are there any easier ways of generating numbers that doesn't contain specific number (such as 8 or 9 in this case?)

2. I was thinking about this throughout the whole project and what if I generate a number such as 27 (less than 3 or 4 digit number) rather than 3 or 4 digit numbers? How would it show 0027 or 027 instead of 27 for the phone numbers?

import java.util.Random;
public class pp0303 {
public static void main (String[] args){
Random generator = new Random();
int first0, first1, first2, second, third, random0;

[Code] ....

RESULTS:

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Cannot invoke replace(char, int) on the primitive type int
Cannot invoke replace(char) on the primitive type int
Syntax error on token "random0", delete this token
at pp0303.main(pp0303.java:15)

View Replies View Related

Modify Class Time2 To Include Tick Method That Increments Time Stored In Object By One Second

Jul 9, 2014

Modify class Time2 to include a tick method that increments the time stored in a Time2 object by one second. Provide method incrementMinute to increment the minute and method incrementHour to increment the hour. The Time2 object should always remain

a) incrementing into the next minute,

b) incrementing into the next hour and

c) incrementing into the next day (i.e., 11:59:59 PM to 12:00:00 AM).

how to manage case 4 stuff and what's the problem of this CODE.

import java.util.Scanner;
public class Time2Test
{
public static void main( String args[] )
{
Scanner input = new Scanner( System.in );
Time2 time = new Time2();
// input
System.out.println( "Enter the time" );
System.out.print( "Hours: " );
time.setHour( input.nextInt() );

[code]....

View Replies View Related

Manually Sorting Array Into Another Array

Jan 28, 2015

This piece of code i cannot change

public class Lab
{
public static void main(string args[]) {
int ar[]={7,5,2,8,4,9,6};
int sorted[]=new int[ar.length];

/// my code is right here this i can change i keep getting array required int found i'm not sure what i'm doing wrong i do know i need 2 for loops and an if statement.

[code]for(i=0;i<ar.length;i++){
for(j=i+1;j<ar.length;j++){
if(ar.length[i]>ar.length[j]
this piece of code cannot change
for(int i = 0; i<sorted.length; i++)
{
system.out.println("sorted[" + i + "] = " + sorted[i]);[/code]

View Replies View Related

Run Jar File From Batch File And CMD Manually

Jun 7, 2014

I get the following error when I try to run my jar file from a Batch file and CMD manually (The batch file is just set to run the jar and record any output to a text file, and open it after).

Exception in thread "main" java.lang.IllegalArgumentException: input == null!
at javax.imageio.ImageIO.read(Unknown Source)
at com.github.bewd.project.main.Main.<init>(Main.java:37)
at com.github.bewd.project.main.Main.main(Main.java:76)

However running from Netbeans, it works perfectly; JFrame and all. I'm not sure if it's something wrong with my classpath (which I don't think is likely) or something in my code that's affecting it, here's the code:

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.math.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

[code]....

View Replies View Related

Applets :: Accessing Java Application Without Adding Site To Java Security

Sep 12, 2014

I have tried running the java application without adding the site to site list in java security tab. But I get a sand box message as APPLICATION BLOCKED BY SECURITY SETTINGS. How to run the java application without adding the site to site list in java security tab.

View Replies View Related

Can Use Java Code From OpenScript Or APIs In Separate Java Program?

Oct 24, 2014

I want to develop a Java program that uses OpenScript APIs to test my applications. The OpenScript framework automatically creates the Java Code so I was thinking of either using this code or create my own using the APIs.
 
I tried both options using NetBeans but I'm getting errors everywhere starting with the library import. I'm pretty new to Java so I'm sure I'm missing a lot of things here. I pasted the code below from the OpenScript framework that want to use in a stand-alone file for your reference.,
 
import oracle.oats.scripting.modules.basic.api.*;
import oracle.oats.scripting.modules.browser.api.*;
import oracle.oats.scripting.modules.functionalTest.api.*;
import oracle.oats.scripting.modules.utilities.api.*;
import oracle.oats.scripting.modules.utilities.api.sql.*;

[Code] ....

View Replies View Related

Java Application With Several Classes All In Same Java File

Apr 9, 2015

I've written a java application with several classes all in the same .java file. It works just fine. Now, I've broken it up so that each class has its own .java file. Still works fine. My next step is to put those classes into a package, but I'm not about to get the program to run.The .java source files are all in /home/user/src

I've set the CLASSPATH to /home/user/src..All of the source files have "package com.myfirm.program" on the first line.I compiled the application with:

javac -d . File1.java File2.java File3.java (etc...)

the compiler created the directory: /home/user/src/com/myfirm/program and put all of the .class files in there.So how do I get the program to run? if I run from /home/usr/src

java File1

I get: Exception in thread "main" java.lang.NoClassDefFoundError: File1 (wrong name: com/myfirm/program/Program)

View Replies View Related

How To Call Java Methods From Different Java File

Apr 14, 2015

I create 2 files:

CircleCalculationMethod.javaMain.java 

In Main.java, How can i call method in CircleCalculationMethod.java ?

Should I put everything in same folder ??Should i do something like "import CircleCalculationMethod.java"Should i do something like create a package ...

I use Eclipse software

View Replies View Related

What Is Difference Between Java SE And Java EE

Sep 19, 2014

The title of Question might seem old and previously asked.But I have a Question that what is difference between javaSE and Java EE.Although I knew what comes under JavaSE and What is under JavaEE.But My question is that.

What happens when we add PATH in our Environment Variable How does Eclipse or Other IDE use it?

Second Question is.

For Java SE we declare a Path Variable but for Java EE we do not add any library?(I know we add some jar file like for Servlet(Servlet-api.jar) and for EJB(Ejb.jar),But What is actaul difference?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved