Set Class Path For One Level Down The Current Directory?

Jun 29, 2014

Can we set the class path for one level down the current directory? My structure is like

binlibresourceshexicon.cmdinside the folder dist.

In this case I could run the .cmd file which has java -cp .;lib;resources client.Test .

c: rycpdist>java hexicon.cmdBut if i put the .cmd file inside bin as like this and run as
c: rycpdistin>java hexicon.cmdI am getting this error Error: Could not find or load main class

Is there any possibility to set the class path in this case

View Replies


ADVERTISEMENT

Finding Source Files In Other Directory With Class Path Option

Apr 23, 2015

I'm having another issue. I have 2 java source files(see below). They are place in the same directory. How do I compile them using classpath?

I have already tried 1st attempt :

javac -cp com.companyname.interview.DuplicateReplace.java DuplicateReplaceTest.java [did not work!]
2nd attempt: javac -cp DuplicateReplace.java DuplicateReplaceTest.java [again, did not work!]
package com.companyname.interview;
public class DuplicateReplace { /* code */}

[Code] ....

View Replies View Related

How To Find The Current Path Of A File

Jun 24, 2014

First of all, i am using ubuntu and jdk8. My problem: displaying the current path of a file in my system Approach: I have a file called dummy.txt in a given directory which have enough permissions and i did the following:

File file=new File("dummy.txt");
System.out.println(file.getAbsolutePath().substring(0,file.getAbsolutePath().lastIndexOf("/")));

I expected to see displayed the current path of the file without the name of the file but it is showing a different path. I just want to display the current path of the file without the name.

View Replies View Related

Adding Entry To PATH Variable In Bin Directory

Dec 24, 2013

I'm using Ubuntu. After unpacking the tar file for JSE 1.7 version 45, in the the bin directory for adding an entry to PATH variable, I typed

javac

and I get the message

The program 'javac' can be found in the following packages:
* default-jdk
* ecj
* gcj-4.6-jdk
* gcj-4.7-jdk
* openjdk-7-jdk
* openjdk-6-jdk
Try: sudo apt-get install <selected package>

Do I have to install these ?

View Replies View Related

How To Write Exact Directory Path To Properties File

Nov 27, 2014

I need to write the exact directory path like C:LisaestUpdate to a properties file.

I am trying it by

FileInputStream in = new FileInputStream(test.properties);
Properties props = new Properties();
props.load(in);
in.close();
 FileOutputStream out = new FileOutputStream(newprop.properties);
props.setProperty("myDirectory","C:Lisa estUpdate" );
props.store(out, null);
out.close();

but the properties file is updated as C:Lisa estUpdate

Extra comes before :.

How can I remove that.

Even I tried it with an command but got same output.

View Replies View Related

JSF :: How To Read CSV File From User Defined Directory Path For Loading To Managed Bean

Jan 10, 2015

I'm using a PrimeFaces UploadedFile xhtml page to select a csv file to read and write using a managed bean (SuperCSVParser.java). The file is read and written to an entity class which then persists the data to a database. The application works fine if I specify a file path on the physical server and select a csv file on that file path. But for the production version I want the user to select ANY file name from ANY directory on their local system.

I know about the FacesContext methods and I've looked at some methods from the java.io File class. Most of these methods are about getting the path from the server, where I want to 'pass' the path String from the client machine to allow the uploaded file to go through. When I try with the below code I get:

java.io.FileNotFoundException: data.csv (The system cannot find the file specified)

I'd like to know what I'm doing as I prefer not to explicitly declare a path in the final app. I'm almost sure that's possible.

<h:form enctype="multipart/form-data">
<p:fileUpload value="#{SuperCsvParser.file}"
mode="simple"
auto="true"

[Code].....

View Replies View Related

Initialization Of Variables At Class Level

Feb 11, 2014

if I declare

class Example
{
int x=10;
......
}

It is not showing any error but when I declare

class Example
{
int x;
x=10;
............
}

it showing compile time error ....

View Replies View Related

Instance Variables Can Be Declared In Class Level Before Or After Use

Jun 3, 2014

From the tutorial:instance variables can be declared in class level before or after use.But the code below does not compile. Why?

Java Code:

public class MainApp {
i=5;
public static void main(String[] args) {
System.out.println("Hello World");
}
int i;
} mh_sh_highlight_all('java');

View Replies View Related

Current Execution Time Of A Class In Java By Running Another Class

Jul 14, 2014

i want to write a class in such a way that i should get the current execution time of another class which is running. I searched in net but it shows only how to calculate the time duration of the current class which is running. But as per my way, i need the execution time of one class from another class. How to do this ?

View Replies View Related

Servlets :: Thread Safety Should Not Use Any Variables Or Objects At Instance / Class Level

Jun 3, 2014

As web server has multiple threads to serve client requests in Thread Pool & to ensure Thread Safety we should not use any variables or Objects at Instance/Class level.But in case of Session Variable which one is the Best Practice as the Session object is used by all the requests to have the same Session ID.

My Code :

public class MyServlet extends HttpServlet {
private static Logger log = Logger.getLogger(ClientRegistrationServlet.class);
private HttpSession session; /* This is used at Instance Level*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

[code]....

View Replies View Related

Assign Current Null Value To Current Date?

Mar 6, 2014

How can i assign current  null value to current date, I only what to assign this if the current value coming from database is null otherwise i must use value from database

public static String getDate(Calendar cal){
        return "" + cal.get(Calendar.DATE) +"/" +
                (cal.get(Calendar.MONTH)+1) + "/" + cal.get(Calendar.YEAR);
    }
try {

[Code] .....

View Replies View Related

Get Access To Either Logger Or LogManager Class And Print Current Configuration

Oct 22, 2014

I want to know if I can get the entire log4j.properties file constructed in Java code. I am not talking about configuring the logger using Java code.I have a logger that is already configured using a file. I want to get access to either Logger or LogManager (any other?) class and print the current configuration that is in memory.

View Replies View Related

Running A Class Outside The Directory

Feb 17, 2014

I have a directories in UNIX:

/home/t_bmf/Java/HelloWorld/src/helloworld :will contain a .java file
/home/t_bmf/Java/HelloWorld/bin :will contain all .class file

Let say a have a code:

package helloworld;
public class HelloWorld {
public static void main(String[] arg) {
System.out.println("Hello World");
}
}

a command to compile this even outside the directory /home/t_bmf/Java/HelloWorld/src/helloworld
javac -d /home/t_bmf/Java/HelloWorld/bin /home/t_bmf/Java/HelloWorld/src/helloworld/HelloWorld.java

This will generate a directory /home/t_bmf/Java/HelloWorld/bin/helloworld and file inside this is HelloWorld.class

To run this program I must be in directory /home/t_bmf/Java/HelloWorld/bin and using this command:

java helloworld.HelloWorld

Question:

I already how to run the HelloWorld.class, but I must be in helloworld /home/t_bmf/Java/HelloWorld/bin to run it. Is there's a way to run the class even when I am not in directory /home/t_bmf/Java/HelloWorld/bin? Let's say I'm in /home/t_bmf, can I still run the HelloWorld.class?

View Replies View Related

Write Interface Directory To Manipulate Entries In Telephone Directory

Mar 12, 2014

this is the following task i am trying to do. Write an interface Directory to manipulate entries in a telephone directory for the University. The interface must support the following operations:

1) The ability to insert new entries into the directory. Entries should be stored in alphabetical order of surname.
2) Delete entries from the directory either by name or number
3) Provide a lookup method that will find the extension no of a member of staff given
his/her name. You should try to make this method run as efficiently as possible.
4) Change a person's telephone number
5) Print the telephone directory in a neatly tabulated fashion.

Write a class ArrayDirectory that implements this interface using an array to store the telephone directory information. The class must store the surname and initial for each member of staff and their telephone extension (a four digit number which may start with a zero). You may find it useful to define a class Entry to store information about individual entries. The entries should be read into the array from a text file consisting of multiple lines in the following format:

Surname<tab>Initials<tab>Telephone extension

The part that i am stuck on is trying to do the entry method, delete entries method, loop up method, change persons telephone number and be able to print it.

View Replies View Related

Servlets :: Url Pattern - Real Directory Vs Virtual Directory

May 26, 2014

Consider the url-pattern:
<url-pattern> /Beer/* </url-pattern>

The web app structure is: -

webapps
|
-->AdviceApp
|
-->WEB-INF
--> {{Beer}} This can be real or virtual.

My book says that /Beer/* can be a real or a virtual directory. What is the difference between the two and how do I create a virtual directory in tomcat ?

View Replies View Related

Class Path With Windows 7

May 28, 2010

I've just got a new computer and i tried to set the class path the way i did with windows xp but it's not working. This is what i have done. I added a Path variable to user variables and added C: Program Files (x86)Javajdk1.6.0_20/bin as the variable value. But when i got to command prompt and type javac HelloWorld.java it just tells me javac is not recognised as an internal or external command.

Also another problem is after trying this and it not working i tried to add a path to the system variables. I added a new path variable but i think once i did that it deleted the one that was already there. Is that going to mess up my computer? What the default path variable for windows 7 is?i've got the right destination as i typed cd to change directory and when i typed C: Program Files (x86)Javajdk1.6.0_20/bin it changed to that. And i noticed if i typed in the destination wrong its just made an error.

View Replies View Related

Need To Specify Path Where Main Class Is Located

Jun 24, 2014

I am trying to apply for a job in testing the following java application.I have received a tool written in Java and I need to run it with the command line:

java -classpath ./bin com.test.Main myinputfile.txt myoutputfile.txt sort....

Main class should receive 3 parameters: inputfile, outputfile, action.

Of course I have installed Java on my computer (Windows env.).

The problem is that I receive this error:"could not find or load main class com.test.Main"

I searched over the Internet and I saw that I need to specify the path where "Main" class is located.

Main class is located in my c: rachelFileManipulatornincomtest. What should I type exactly in order to run this Main class?

View Replies View Related

How To Create JavaScript To Find Current Month And Current Day Of Month

Mar 17, 2015

I want to be able to use the current date to solve a math problem, specifically as follows:If today is March 17, the math problem of the day should be:

(Month times Day of Month) + 99 = Answer of the Day

(3 x 17) + 99 = 150

How can I create a java script to find the current month and the current day of month, multiple those two together, then add 99 and display the answer as a result.

View Replies View Related

Java Network Simulator - Specifying Jar Class Path

Sep 4, 2014

I have downloaded jns-1.7 & tried to run an example program "Simulator.java" by specifing the jar classpath while compiling as "javac -cp <path-to-jns-jar-file> Simulator.java". But i got 21 errors as follows:

Simulator.java:3: error: package jns.command does not exist
import jns.command.Command;
^
Simulator.java:4: error: package jns.element does not exist
import jns.element.Element;

[Code] ...

21 errors

I am trying my hand on JNS as i need to deveop a key-distribution scheme (random Key-Distribution scheme) using a simulator. As i have experience in java, i thought to use JNS instead of NS2/NS3 which seems very complex to me.

View Replies View Related

Java EE SDK :: How To Set The Class Path When Using Technology In Eclipse

Nov 1, 2011

I'm developing a JavaEE system with several applications on a Weblogic AS (10.3.5) using Eclipse indigo with OEPE plugin. I turned my computer off, turned it back on, started the eclipse, and all of a sudden I get class-path errors all over the place (didn't change a thing).

Now let me get this straight:

1. Say I have an application with one EAR project that contains an EJB project and an EJBClient project (both in the deployment assembly).
2. I have written a new regular Java project, and I want to use it in both the EJB and EJBClient projects (it needs to be visible to them).
3. As far as I know, I can simply add this Java project to the EAR project's deployment assembly, and it will be visible to the EJB and EJBClient projects.
4. This has been working for me so far, but now I get class-path errors and I have to add this Java project to the build path of each project.

How should I set the class-path when using JavaEE technology in Eclipse?

View Replies View Related

Use Relative Path In Place Of Absolute Path

Nov 7, 2014

I am copying the xml files from one folder to other folder, in the source folder, i have some files which have some content like "backing File="$IDP_ ROOT/metadata/iPAU-SP-metadata.xml" but while writing to the destination folder.i am replacing the "$IDP_ROOT" with my current working directory. The entire copying of files is for deploying into tomcat server. The copying is done only when server starts for the first time.Problem: If i change the folder name from my root path in my machine after i run the server,the entire process will be stopped because the destination folder files already contains the content which is with existed files names or folder names.

So i want to change it to relative path instead absolute path. What is the best way to do it? Please look at code below:

[ // Getting the current working directory
String currentdir = new File(".").getAbsoluteFile().getParent() + File.separator;

if(currentdir.indexOf("ControlPanel")!=-1){
rootPath=currentdir.substring(0, currentdir.indexOf("ControlPanel"));
}else{
rootPath=currentdir;

[code]....

View Replies View Related

Creating A Level Editor GUI

Nov 17, 2014

I am working on a game engine with java. I have come to the final stages of the development of this engine now and need a small hand. For this i am using java's built in libary for graphics. and am strugling to create a nice looking GUi with it, What i need:

The class extends the canvas class and adds it to the jframe, i have set the window up as standard and added a menubar, and net the canvas, what I want to do.

For those of you that have used application such as tiled (shown here [URL] .....) what i am wanting to do is create a gui around the canvas similar to this where the parts on the right are resizable up and down and in and out. i was wondering how i would go about incorporating this.

View Replies View Related

Can't Override A Method - It Still Ask For Level 1.5 Or Greater

Apr 29, 2014

I'm using "standard-kepler-SR2-win32-x86_64" and have installed "jdk-8u5-windows-x64".

But eventhough I can't override a methode like that "@override", it still says me:"annotations are only available, if source lever is 1.5 or greater".

Fine, therefore I installad "jdk-8u5-windows-x64", its the higest one on that oracle side, what else is needed?

View Replies View Related

JSF :: How To Handle Lower Level Exception

Jan 7, 2015

I have come across some code where it attempts to save an entity to a database, but before it does it validates that the name of the entity is unique. If it is not unique it throws a runtime exception. This results in the ugly default exception web page being displayed. Is there any way to propagate this back to the JSF page where the user enters and clicks the form button to save the entity? The page already handles some error cases such as "field required" using the h:inputText's 'required' attribute. Need something more for name validation.

View Replies View Related

Object Level Locking In Java Threads

Apr 16, 2014

I know that below code would put a lock on current instance of DemoClass, What I am not sure of is the role of lock on Object Class in second example. How does below works - Is it putting a lock on Object Class? If yes how will putting a lock on Object? I mean, locking DemoClass ensure no two threads access it concurrently, how does this apply to Object class?

private final Object lock = new Object();
synchronized (lock)
public class DemoClass
{
public void demoMethod(){
synchronized (this)

[code]....

View Replies View Related

Level Order Traversal - 2D Display Of Trees

Apr 6, 2015

We are working with LinkedBinarySearchTrees. One of specs on my assignment is to "Using a level-order traversal, create a 2-D display of your trees, using the forward and back slashes as the branch lines. The tree nodes should be spaced proportionally to show the structure of the tree neatly."

View Replies View Related







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